erp1022
asked on
VBA for Excel Spreadsheet
Hello,
Could someone tell me how to find all of the records in a column that start with the letter 'A', and if they start with 'A' do a mid function. =mid(A2, 2, 5)
Thanks.
Could someone tell me how to find all of the records in a column that start with the letter 'A', and if they start with 'A' do a mid function. =mid(A2, 2, 5)
Thanks.
ASKER
I actually need VBA for this. It's for an end user and I would like for them to be able to just press a button. (run a macro)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That won't work either. There will be a different number of records in my file each month. What I need is VBA that will go through the whole column and if it begins with an A, strip it off, then do the mid function.
If you highlight the whole column before performing the find function, that should help, that way it will only look in that column
please provide an excel file
ASKER
Here's what the VBA looks like after recording the macro. In the 2nd to last and last line where it says 'Range' can I just change that to B2:B2 and that will take care of the whole column no matter how many records?
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[1],1)=""A"", MID(RC[1], 2, 5), RC[1])"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B22 04")
Range("B2:B2204").Select
End Sub
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[1],1)=""A"", MID(RC[1], 2, 5), RC[1])"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B22
Range("B2:B2204").Select
End Sub
Not B2:B2, but you could do
B2:B(choose a number that you think would be the maximum number of rows like 60,000)
B2:B(choose a number that you think would be the maximum number of rows like 60,000)
ASKER
There should be some function, I'm not a VBA developer (obviously) but I think it's transpose or array or count? Something that will count the actual number of records and update only that range. I really don't know how many records my file will be and don't like putting in a random number to account for the range.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay, I just got back from vacation. I will test this either later on today or early tomorrow.
Thanks.
Thanks.
=IF(LEFT(A1,1)="A",MID(A1,
This will extract the information that you want. Then you could Autofilter this column to list all excepet blanks and copy the result to a new sheet.
jppinto