Excel Macro range from Mr Excel


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Macro range
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

1S1
Board Regular


Joined: 04 Dec 2002
Posts: 19


Status: Offline

 Reply with quote  

Macro range

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

Post Thu Apr 22, 2004 1:01 pm 
 View user's profile Send private message

jmiskey
Board Master
Board Master


Joined: 02 Aug 2002
Posts: 3460

Flag: Usa

Status: Offline

 Reply with quote  

Re: Macro range

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
_________________
Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!

Post Thu Apr 22, 2004 1:11 pm 
 View user's profile Send private message

jimboy
Board Master
Board  Master


Joined: 12 Apr 2002
Posts: 1826

Flag: England

Status: Offline

 Reply with quote  

Re: Macro range

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


Post Thu Apr 22, 2004 1:15 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.