Relative Content

Tag Archive for excelvbafor-loopif-statement

How can I run If statements on every sheet that contains specific text using VBA?

I am trying to create a macro that will run If statements on every sheet with “(M)” at the end. I just need the macro to check cell “G8” in every worksheet with “(M)” at the end to see if there is a formula. If there is, then copy the formula over to “M8”. If there isn’t a formula then move on to the next sheet. Right now, the macro is doing nothing. I need it to work on all sheets with (M) at the end because this is a workbook where new sheets will be added and current sheets may be deleted, and I would like for the macro to work without having to change it when the sheets are changed.

workbook open event copy consecutive numbers to consecutive cells

I am trying to create an Excel file which will be updated up on opening using the workbook open event. I make one cell a counter, which will count starting 1 when the file is opened first, then 2 when the file is opened second time and so on. I want to copy the value of the counter to the cells in row 3 starting from column H, that is, H1 = 1, I1 =2 etc. The problem is whenever I open the first time, 1 is copied to all the cells. Please see the screenshot below:
enter image description here

Excel VBA workbook open event copy consecutive numbers to consecutive cells

I am trying to create an excel file which will be updated up on opening using the workbook open event. I make one cell a counter, which will count starting 1 when the file is opened first then 2 when the file is opened second time and so on. I want to copy value of the counter to the cells in row 3 starting from column H, that is, H1 = 1, I1 =2 etc. The problem is whenever I open the first time, 1 is copied to all the cells. Please see the screenshot below:
enter image description here