Macro range

1S1

Board Regular
Joined
Dec 3, 2002
Messages
95
I receive a sheet of data daily, containing a list of numbers. The number are of several digits long and I convert them all in to six digit numbers in column “B” with the following formula. =text(a1,“000000”) I then click on the bottom right corner of cell A1 and the formula populates down. I then Special pates (values) the result in to cell A1’

I have now recorded a macro to do this process, but when this was set up there were only 500 rows of data, so when I receive a list containing 800 rows of data the macro only works up to row 500.
Can the macro be altered to accommodate as many rows as there are rows of data?

The macro reads:

Range("E3").Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-3],""000000"")"
Range("E3").Select
Selection.AutoFill Destination:=Range("E3:E500"), Type:=xlFillDefault
Range("E3:E500").Select
Selection.Copy
ActiveWindow.ScrollRow = 1
Range("B3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("E:E").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("E3").Select
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try capturing the last row, something like:

' Capture last row using column A
Dim myLastRow as Long
myLastRow = Range("A65536").End(xlUp).Row

Range("E3").Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-3],""000000"")"
Range("E3").Select
Selection.AutoFill Destination:=Range("E3:E" & myLastRow), Type:=xlFillDefault
Range("E3:E500").Select
Selection.Copy
ActiveWindow.ScrollRow = 1
Range("B3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("E:E").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("E3").Select
End Sub
 
Upvote 0
Or this shorter version;

Code:
With Range("E3:E" & Range("B65536").End(xlUp).Row)
.Formula = "=TEXT(RC[-3],""000000"")"
.NumberFormat = "@"
.Value = .Value
.Copy .Offset(0, -3)
.Clear
End With
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,013
Members
448,935
Latest member
ijat

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