
Originally Posted by
rainwilds
The code you posted above is perfect, except it won't seem to run when opening the file; I have to force it by running from the VBA editor. Not sure why as I said to trust the macro document.
The next hurdle is to apply this exact code (with range differences) to other columns, only entering the loop if the cell/column does not already contain a value. So I need to find columns to see if their value is blank (ignoring those that aren't), then enter into the loop to test/apply the static values (as previous).
What would be the best testing code to find the columns? What I know is the names of the columns specifically like this "Rem. JUL19 C2" and "Rem. AUG19 C2"; where only the month JUL/AUG/SEP etc. is changing.
Thanks for all the help Richard.
David
Did you put the code in the Workbook Open Event. In the VBA you need to double click the Workbook object in the VBA Project Window list of objects (sheets, workbook..etc and select the let hand drop down to select the Workbook object and then the Open event from the right hand drop down.
The approach I always adopt for checking whether a particular column (or row) is blank is to use a helper row of cells above the columns of data and in that cell use a function to identify whether the range of cells is blank. Typically that would be something like
which will return 0 if the range is all blanks. Then in the loop the macro just needs to check the row of helper cells. That said would it really matter of you copied and pasted blank cells anyway. I agree you'd be processing some columns that aren't really neceesary but I suspec the very small time overhead would not be noticeable.
Bookmarks