A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro in Excel



 
 
Thread Tools Display Modes
  #1  
Old March 11th, 2010, 05:20 PM posted to microsoft.public.excel.misc
Christina
external usenet poster
 
Posts: 282
Default Macro in Excel

I am creating a macro, and need to select the next cell down after the
selected cell, and then to run the entire macro until the end of the data on
the sheet.

I am new, and would like very basic instructions, please.


Thanks, Cristina


  #2  
Old March 11th, 2010, 05:31 PM posted to microsoft.public.excel.misc
Mike H
external usenet poster
 
Posts: 8,419
Default Macro in Excel

Christina,

Selecting cells is a poor way of doing what you want because it takes time
and you can almost certainly achieve what you want without selecting
anything. The snippet of code below loops through the used range of column A

Sub Christina()
Dim MyRange As Range
Dim LastRow As Long
Set Sht = Sheets("Sheet1")
LastRow = Sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Sht.Range("A1:A" & LastRow)
For Each c In MyRange
'your code
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Christina" wrote:

I am creating a macro, and need to select the next cell down after the
selected cell, and then to run the entire macro until the end of the data on
the sheet.

I am new, and would like very basic instructions, please.


Thanks, Cristina


  #3  
Old March 11th, 2010, 05:55 PM posted to microsoft.public.excel.misc
Christina
external usenet poster
 
Posts: 282
Default Macro in Excel

Thanks for your answer, but my knowledge is limited. I don't know codes.
What I am doing is copying data next to columns as in the example below.

A B C D
Vendor ID
Brodies
Invoice #1 6/3/2010 $10.00
Invoice #2 6/4/2010 $20.00
Invoice #3 6/5/2010 $30.00
Invoice #4 6/6/2010 $40.00

Vendor ID
Caladium
Invoice #5 6/3/2010 $10.00
Invoice #6 6/4/2010 $20.00
Invoice #7 6/5/2010 $30.00
Invoice #8 6/6/2010 $40.00

I made a macro and have been able to copy the vendor ID next to the invoice
Numbers for Brodie, then a search for "vendor ID", and selected the cell
above CALADIUM. then would like to move to next cell below and copy the name
Caladium next to the invoice number(will copy the codes already in the macro)
and continue down the sheet until there is no more data.


Thanks,


Cristina






"Mike H" wrote:

Christina,

Selecting cells is a poor way of doing what you want because it takes time
and you can almost certainly achieve what you want without selecting
anything. The snippet of code below loops through the used range of column A

Sub Christina()
Dim MyRange As Range
Dim LastRow As Long
Set Sht = Sheets("Sheet1")
LastRow = Sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Sht.Range("A1:A" & LastRow)
For Each c In MyRange
'your code
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Christina" wrote:

I am creating a macro, and need to select the next cell down after the
selected cell, and then to run the entire macro until the end of the data on
the sheet.

I am new, and would like very basic instructions, please.


Thanks, Cristina


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.