Restarting a macro
The following is a copy of my macro. Where would I place your code to make my
cursor automatically loop back to the first column of my spreadsheet after
the mac has read the very last column in the spreadsheet?
Function FunctNextCookie(Optional blnHide As Boolean)
Sheets("C_Data").Select
Cells(3, ActiveCell.Column).Select
' Moves cursor to row 3.
ActiveCell.Offset(0, 1).Range("A1").Select
' Selects next SKU.
Selection.Copy
Sheets("Cookie").Select
Range("C5").PasteSpecial Paste:=xlValues
' Does not HideZeroUsage if called by ReportAll.
If blnHide = True Then HideZeroUsage
End Function
"Dave Peterson" wrote:
I don't quite understand what you're doing, but it sounds like you're selecting
cells. It's not usually necessary to select cells to work on them.
But you could use
if activecell.column = activesheet.columns.count then
activesheet.cells(activecell.row+1,1).select
end if
BR wrote:
Thanks. I am just trying to get my cursor back to the beginning of my
worksheet after my macro has moved it to the last column, by way of the macro
loop, without having to manually move the cursor. Where would I place your
code?
"Dave Peterson" wrote:
Maybe you could just loop between column 1 and the maximum column:
dim cCtr as long
for cctr = 1 to activesheet.columns.count
'do something
next cctr
Say you want to loop through rows looking through columns:
dim cCtr as long
dim rCtr as long
for rctr = 1 to 10
for cctr = 1 to activesheet.columns.count
msgbox activesheet.cells(rctr,cctr).value
next cctr
next rctr
=====
If this doesn't help (and I'd be kind of surprised if it did!), you may want to
add some more detail to your question.
BR wrote:
I have a macro that loops from column A to column IV(the last column in
Excel). Once the last column is read how can I cause my macro to restart at
the column A again? Can I set my macro to return to column A after it reads
column IV. What would be the macro syntax for that? Thanks.
--
Dave Peterson
--
Dave Peterson
|