![]() |
Select dynamic data in 2 columns, and repeat macro to next sheet
Can someone help me with a macro? I tried recording this, but the issue I am
having is that the data changes from sheet to sheet, and would change month to month, so it won't always be the same. I have about 15 sheets in my workbook, all set up with the same columns. I am trying to select all cells with data in them in columns C and D, then will run the rest of my macro I have already built. I just can't figure out what to add to my macro that will select only cells in columns C & D with data in them. What I want it to do, select all cells in columns C & D with data in them, then my macro multiples the data in those cells times -1 to change the debits and credits. I have everything else done but the selection. I will run this macro on each sheet, so if you can help me figure out a way to run the macro, then select the next sheet, run the macro, etc. to the end, that would be great too! Otherwise I'm selecting each sheet, running the macro, then proceeding to the next sheet. Thanks in advance for any help you can give me!! |
Select dynamic data in 2 columns, and repeat macro to next sheet
Sub YourMacro()
For Each ws In Worksheets Sheets(ws.Name).Activate 'Choose one of the following lines: 'Use this line if data is from a constant Columns("C:D").SpecialCells(xlCellTypeConstants, 1).Select 'Use this line if data is from a formula 'Columns("C:D").SpecialCells(xlCellTypeFormulas, 1).Select For Each cell In Selection cell.Value = cell.Value * -1 Next cell 'Any other coding you want done on sheet 'would got here Next End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "Tasha" wrote: Can someone help me with a macro? I tried recording this, but the issue I am having is that the data changes from sheet to sheet, and would change month to month, so it won't always be the same. I have about 15 sheets in my workbook, all set up with the same columns. I am trying to select all cells with data in them in columns C and D, then will run the rest of my macro I have already built. I just can't figure out what to add to my macro that will select only cells in columns C & D with data in them. What I want it to do, select all cells in columns C & D with data in them, then my macro multiples the data in those cells times -1 to change the debits and credits. I have everything else done but the selection. I will run this macro on each sheet, so if you can help me figure out a way to run the macro, then select the next sheet, run the macro, etc. to the end, that would be great too! Otherwise I'm selecting each sheet, running the macro, then proceeding to the next sheet. Thanks in advance for any help you can give me!! |
Select dynamic data in 2 columns, and repeat macro to next she
Worked like a charm, thank you so much Luke!!!
"Luke M" wrote: Sub YourMacro() For Each ws In Worksheets Sheets(ws.Name).Activate 'Choose one of the following lines: 'Use this line if data is from a constant Columns("C:D").SpecialCells(xlCellTypeConstants, 1).Select 'Use this line if data is from a formula 'Columns("C:D").SpecialCells(xlCellTypeFormulas, 1).Select For Each cell In Selection cell.Value = cell.Value * -1 Next cell 'Any other coding you want done on sheet 'would got here Next End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "Tasha" wrote: Can someone help me with a macro? I tried recording this, but the issue I am having is that the data changes from sheet to sheet, and would change month to month, so it won't always be the same. I have about 15 sheets in my workbook, all set up with the same columns. I am trying to select all cells with data in them in columns C and D, then will run the rest of my macro I have already built. I just can't figure out what to add to my macro that will select only cells in columns C & D with data in them. What I want it to do, select all cells in columns C & D with data in them, then my macro multiples the data in those cells times -1 to change the debits and credits. I have everything else done but the selection. I will run this macro on each sheet, so if you can help me figure out a way to run the macro, then select the next sheet, run the macro, etc. to the end, that would be great too! Otherwise I'm selecting each sheet, running the macro, then proceeding to the next sheet. Thanks in advance for any help you can give me!! |
All times are GMT +1. The time now is 08:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com