Macro using the F2 key.

alexaronson

Active Member
Joined
Sep 30, 2005
Messages
314
I have a large mass of data.
Some cells have values like this "8492".
Others have vlues like this "00009".

I have to get the cells to drop the leading zeros.
I have tried changing the format of the cells to numbers, but the zero's wont drop.

I know if I select the cell one at a time and hit the F2 key, the zero's magically disappear.

Due to the size of the data, I can't F2 every cell.

What I am looking for is a macro, that will go through a column of data, select the data, hit the F2 key, and then go to the next cell.

I created a macro that mimincs what I do manually and this is what I get.


Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/17/2005 by aaronso
'

'
    ActiveCell.FormulaR1C1 = "26909"
    Range("D279").Select
    ActiveCell.FormulaR1C1 = "26910"
    Range("D280").Select
    ActiveCell.FormulaR1C1 = "27030"
    Range("D281").Select
    ActiveCell.FormulaR1C1 = "27033"
    Range("D282").Select
    ActiveCell.FormulaR1C1 = "28018"
    Range("D283").Select
End Sub

So with that thought process I tried this:

Code:
Sub CleanZeros()
Application.ScreenUpdating = False

For j = 1 To 40000
ActiveCell.FormulaR1C1 = Row()
       j = j + 1
           
Next
Application.ScreenUpdating = False
End Sub

Can anyone help?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi, alexaronson,
you don't necessarely need a macro

try one of these methods
method 1.
select data
menu data / text to columns / finish (whatever settings are there)
method 2.
type 1 in any cell (or type 0)
copy there cell
select data
rightclick
choose pastespecial
paste values + check multiply (or add)

kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,741
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top