Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
BR
 
Posts: n/a
Default Restarting a macro

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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Restarting a macro

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
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
BR
 
Posts: n/a
Default Restarting a macro

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

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Restarting a macro

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
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
BR
 
Posts: n/a
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Restarting a macro

Maybe...

Option Explicit

Function FunctNextCookie(Optional blnHide As Boolean)
Sheets("C_Data").Select
Cells(3, ActiveCell.Column).Select
' Moves cursor to row 3.
If ActiveCell.Column = ActiveSheet.Columns.Count Then
ActiveSheet.Cells(ActiveCell.Row + 1, 1).Select
Else
ActiveCell.Offset(0, 1).Range("A1").Select
End If
' 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



BR wrote:

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


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
BR
 
Posts: n/a
Default Restarting a macro

Is there a simply way to have the cursor in an Excel spreadsheet, once it
reaches a certain cell due to macro movement, to automatically jump back to
Column A.

"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

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Restarting a macro

You might be able to use a worksheet_change event.

But I think that most people would shy away from selecting cells in their code.



BR wrote:

Is there a simply way to have the cursor in an Excel spreadsheet, once it
reaches a certain cell due to macro movement, to automatically jump back to
Column A.

"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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Can T Get Macro To Run! Nipper New Users to Excel 2 November 4th 05 04:48 AM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"