If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Macros
I'm new at running macros and I currently use the "record macro" button. I
need to run a macro that recognizes "only populated data" in the columns so I can copy an paste it into another worksheet. The number of rows with data in them will change daily and I need the macro to compensate. You can do this with a filter and only filter "non blanks" but the macro does not adjust accordingly the next day if it record it. Any assistance would be great! -- Deb |
#2
|
|||
|
|||
Macros
Debbie,
Without seeing your code it's difficult but if your copying data then somewhere in your recorded macro you will have a line simliar to Range("A1:A10").Select Selection.Copy Now this as you have discovered is a fixed range that you need to make dynamic so first find the last row with lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row Then create the range and copy with this Range("A1:A" & lastrow).Copy Note unlike a recorded macro i did it without selecting anything -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Debbie" wrote: I'm new at running macros and I currently use the "record macro" button. I need to run a macro that recognizes "only populated data" in the columns so I can copy an paste it into another worksheet. The number of rows with data in them will change daily and I need the macro to compensate. You can do this with a filter and only filter "non blanks" but the macro does not adjust accordingly the next day if it record it. Any assistance would be great! -- Deb |
#3
|
|||
|
|||
Macros
When I type in lastrow = Cells(Cells.Rows.Count, "A").End(x1Up).Row the macro
gives me an error staying last row is empty. Below is an example of the recorded macro I was using. Range("V7").Select Selection.AutoFilter Field:=20, Criteria1:="" Range("V7:AI7").Select Range(Selection, Selection.End(xlToRight)).Select Range("V7:AS350").Select Application.CutCopyMode = False Selection.Copy Sheets("Combined Upload File").Select Range("A3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False I originally used a filter to select only nonblank rows but found that would not work. My next options was to go the other spectrum and copy all of the rows (whether there was data or not). The example above shows this scenario. What I would prefer to do is only copy the rows that have data so the macro recognizes each day those rows that have data within column "V". The data could begin to populate in row 7 but row 7 may or may not be populated depending on if the formula that feeds into V7 provides any results. Column V - AI results are determined by a formula -- Debbie Sherman "Mike H" wrote: Debbie, Without seeing your code it's difficult but if your copying data then somewhere in your recorded macro you will have a line simliar to Range("A1:A10").Select Selection.Copy Now this as you have discovered is a fixed range that you need to make dynamic so first find the last row with lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row Then create the range and copy with this Range("A1:A" & lastrow).Copy Note unlike a recorded macro i did it without selecting anything -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Debbie" wrote: I'm new at running macros and I currently use the "record macro" button. I need to run a macro that recognizes "only populated data" in the columns so I can copy an paste it into another worksheet. The number of rows with data in them will change daily and I need the macro to compensate. You can do this with a filter and only filter "non blanks" but the macro does not adjust accordingly the next day if it record it. Any assistance would be great! -- Deb |
Thread Tools | |
Display Modes | |
|
|