Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Selecting/Copying Variable Areas

Hi

I have a template which uses formulas to drag data from an input sheet
through to a worksheet which manipulates the data. The number of rows of data
on the input sheet is variable. I cannot use activerange because I do not
want to select cells containing formulas which have not resulted in data
being pulled through. What I need is a macro which checks the rows in column
A to see how many have text data pulled through and ignors the rest where
there is a formula but which has not dragged data from the input sheet and
then to select these rows.

This selection would start at A4 (or the user could select the start cell
manually). The area would be limited by the last column which contains text
in any row (and again not formulas).

Thanks for any assistance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Selecting/Copying Variable Areas

Dim lastrow as Long, realLastRow as Long
lastrow = cells(rows.count,1).End(xlup)
for i = lastrow to 4 step -1
if len(trim(cells(i,1).text)) 0 then
reallastrow = i
exit for
end if
Next
Range("A4:A" & reallastrow).Select

would be a start.

--
Regards,
Tom Ogilvy


"Constantly Amazed" wrote:

Hi

I have a template which uses formulas to drag data from an input sheet
through to a worksheet which manipulates the data. The number of rows of data
on the input sheet is variable. I cannot use activerange because I do not
want to select cells containing formulas which have not resulted in data
being pulled through. What I need is a macro which checks the rows in column
A to see how many have text data pulled through and ignors the rest where
there is a formula but which has not dragged data from the input sheet and
then to select these rows.

This selection would start at A4 (or the user could select the start cell
manually). The area would be limited by the last column which contains text
in any row (and again not formulas).

Thanks for any assistance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Selecting/Copying Variable Areas

Hi Tom

Thanks for the input. However, when I try and run this code I get a run
time error '13' Type mismatch. The debug then highlights the line: lastrow =
cells(rows.count,1).End(xlup)

Can you help?

G

"Tom Ogilvy" wrote:

Dim lastrow as Long, realLastRow as Long
lastrow = cells(rows.count,1).End(xlup)
for i = lastrow to 4 step -1
if len(trim(cells(i,1).text)) 0 then
reallastrow = i
exit for
end if
Next
Range("A4:A" & reallastrow).Select

would be a start.

--
Regards,
Tom Ogilvy


"Constantly Amazed" wrote:

Hi

I have a template which uses formulas to drag data from an input sheet
through to a worksheet which manipulates the data. The number of rows of data
on the input sheet is variable. I cannot use activerange because I do not
want to select cells containing formulas which have not resulted in data
being pulled through. What I need is a macro which checks the rows in column
A to see how many have text data pulled through and ignors the rest where
there is a formula but which has not dragged data from the input sheet and
then to select these rows.

This selection would start at A4 (or the user could select the start cell
manually). The area would be limited by the last column which contains text
in any row (and again not formulas).

Thanks for any assistance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Selecting/Copying Variable Areas

Dim lastrow as Long, realLastRow as Long
lastrow = cells(rows.count,1).End(xlup).row '<==
for i = lastrow to 4 step -1
if len(trim(cells(i,1).text)) 0 then
reallastrow = i
exit for
end if
Next
Range("A4:A" & reallastrow).Select

--
Regards,
Tom Ogilvy


"Constantly Amazed" wrote:

Hi Tom

Thanks for the input. However, when I try and run this code I get a run
time error '13' Type mismatch. The debug then highlights the line: lastrow =
cells(rows.count,1).End(xlup)

Can you help?

G

"Tom Ogilvy" wrote:

Dim lastrow as Long, realLastRow as Long
lastrow = cells(rows.count,1).End(xlup)
for i = lastrow to 4 step -1
if len(trim(cells(i,1).text)) 0 then
reallastrow = i
exit for
end if
Next
Range("A4:A" & reallastrow).Select

would be a start.

--
Regards,
Tom Ogilvy


"Constantly Amazed" wrote:

Hi

I have a template which uses formulas to drag data from an input sheet
through to a worksheet which manipulates the data. The number of rows of data
on the input sheet is variable. I cannot use activerange because I do not
want to select cells containing formulas which have not resulted in data
being pulled through. What I need is a macro which checks the rows in column
A to see how many have text data pulled through and ignors the rest where
there is a formula but which has not dragged data from the input sheet and
then to select these rows.

This selection would start at A4 (or the user could select the start cell
manually). The area would be limited by the last column which contains text
in any row (and again not formulas).

Thanks for any assistance.

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
How do I perform summation over variable areas? Pithecanthropus Excel Discussion (Misc queries) 1 August 8th 07 07:02 PM
Copying print areas and Row and Chart Headings are displayed Barb Reinhardt Charts and Charting in Excel 2 January 24th 07 03:51 PM
Variable Ranges for Print Areas Graham[_6_] Excel Programming 1 August 3rd 04 11:11 PM
Deleting "variable" areas in a worksheet adidas2121 Excel Programming 3 May 19th 04 04:45 AM
copying areas and macro loops dynamicsoul Excel Programming 3 September 12th 03 09:43 PM


All times are GMT +1. The time now is 01:00 PM.

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

About Us

"It's about Microsoft Excel"