#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 90
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 90
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"