A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macros



 
 
Thread Tools Display Modes
  #1  
Old March 18th, 2010, 03:26 PM posted to microsoft.public.excel.worksheet.functions
Debbie
external usenet poster
 
Posts: 342
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  
Old March 18th, 2010, 03:53 PM posted to microsoft.public.excel.worksheet.functions
Mike H
external usenet poster
 
Posts: 8,419
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  
Old March 19th, 2010, 02:25 PM posted to microsoft.public.excel.worksheet.functions
Debbie
external usenet poster
 
Posts: 342
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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:11 AM.


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