Repeat Macro

T

tvkodde26

I need help in creating a macro that will repeat an easy command. I
have Column A full of numbers, some are formatted General and others
are formatted Text. For Vlookup purposes I need them all formatted as
General.

How would I build a Macro that goes to cell A1 and complete (Enter +
F2) to convert it to general and then it moves to cell A2 and repeats
the same command, etc.....

Thanks for any help.

Travis
 
R

Ron de Bruin

Hi tvkodde26

If I understand you correct this will work for you?

Columns("A").NumberFormat = "General"
 
B

Bob Phillips

For i = 1 To Cells(Rows.Count,"A").End(xlUp).Row
With Activecell
.Value = .Value
End With
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

Typo

For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
With Cells(i, "A")
.Value = .Value
.NumberFormat = "General"
End With
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
H

Harlan Grove

tvkodde26 wrote...
I need help in creating a macro that will repeat an easy command. I
have Column A full of numbers, some are formatted General and others
are formatted Text. For Vlookup purposes I need them all formatted as
General.

How would I build a Macro that goes to cell A1 and complete (Enter +
F2) to convert it to general and then it moves to cell A2 and repeats
the same command, etc.....

Formatting doesn't affect contents. Do you mean some of the cells
contain text that looks like numbers and the remaining cells contain
numbers? If so, do you want to permanently convert the cells containing
text into numbers? If so, the simplest way is to select all cells in
col A, run Data > Text to Columns, and immediately click the Finish
button.

If you only want lookup formulas to treat all values in col A as
numeric, you could use INDEX/MATCH rather than VLOOKUP. If your
intended formula were =VLOOKUP(x,A1:Z999,y), then use the array formula

=INDEX(A1:Z999,MATCH(x,--A1:A999),y)

If you're using a FALSE or zero 4th argument to VLOOKUP, use a zero 3rd
argument to MATCH in the formula above. Then again, if all values in
your lookup table should be numbers, you could use the array formula

=VLOOKUP(x,--A1:Z999,y)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top