Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Editing a simple macro | Excel Worksheet Functions | |||
Can T Get Macro To Run! | New Users to Excel | |||
Closing File Error | Excel Discussion (Misc queries) | |||
Help with macro looping and color query function | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) |