Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm assuming here that what you mean by "I would like that to move across after the macro is run." is that you want the named ranges to move across.</p> <p>I have a spreadsheet for tracking time by the week, and the "first" sheet is the active one. When the week is over with, I copy the entire active sheet to a new sheet. There are totals I want carry over from the prior week, so I preserve that data. I do that by having 3 columns: current week total, old (prior weeks') total, new total. I paste values from new total to old total. Then I clear out the cells used for input.</p> <p>My every instinct was (is) to use named cells, but in this case I concluded it was not the right thing to do. I just used the cell ranges (A1, K2:K0, etc.) The problem is that names are not local to each sheet, so you'd have to move the names from the old sheet to the new, and that is just not worth the effort. Also, in this case, the alternative of creating similar names that are unique to each sheet (e.g., Mon-FriWeek1, Mon-FriWeek2, etc.) doesn't get you anything practical over Week1!A1:A10, etc. -- except maybe self-satisfaction that you used names like you're "supposed" to. That's my opinion anyway!</p> <p>And maybe this might help: in my spreadsheet rows can be added/deleted from one week to the next. In order to allow for that and still avoid named ranges, I mimic going to a column that has a formula in each row, and pressing Shift + End then the down arrow. The selection will stop on the last cell that has something entered. Here's the code for that (the first row is a header/label):</p> <pre><code> 'Copy New Total Hours as PasteValues to Old Total Dim lastRow As Long Range("K1").Select Range(Selection, Selection.End(xlDown)).Select lastRow = Selection.Rows(Selection.Rows.Count).Row + 1 Range("K2:K" &amp; CStr(lastRow)).Select Selection.Copy Range("J2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False </code></pre> <p>You do need to keep at least one row in there, or it (and a great many other things in my case) doesn't work. But that suits my needs just fine.</p> <p>I hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload