Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find last col with data

Data is inserted by a server into a template sheet. My
code copies filtered rows to new sheets and creates
PivotTables. This works fine as long as all 20 columns
contain data.

However, if only col 1 - n have data then an error
message says something like "more than one row is
needed". (Col headings on row one are always filled).

So my question is: how can I replace "20" in the code
below with the number of the last col used for data.
(Cols are always filled left to right).

Set rng = Range(Cells(1, 1), Cells(Rows.Count, 20).End
(xlUp))

Thanks!
Ulf


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Find last col with data

Ulf

Something along these lines perhaps:

Sub test()
Dim Rng As Range

Set Rng = Range(Cells(1, 1), _
Cells(Rows.Count, Cells(1, 256).End(xlToLeft).Column).End(xlUp))

Rng.Select

End Sub


--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"ulfb" skrev i en meddelelse
...
Data is inserted by a server into a template sheet. My
code copies filtered rows to new sheets and creates
PivotTables. This works fine as long as all 20 columns
contain data.

However, if only col 1 - n have data then an error
message says something like "more than one row is
needed". (Col headings on row one are always filled).

So my question is: how can I replace "20" in the code
below with the number of the last col used for data.
(Cols are always filled left to right).

Set rng = Range(Cells(1, 1), Cells(Rows.Count, 20).End
(xlUp))

Thanks!
Ulf




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 find the cell/data the closest/nearest to another data? V Excel Worksheet Functions 8 February 25th 09 04:20 AM
Find formatting doesn't work: "Excel cannot find data" Kasama Excel Discussion (Misc queries) 1 August 18th 06 01:40 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
The match and lookup functions can find literal data but not the same data referenced from a cell Jeff Melvaine Excel Discussion (Misc queries) 3 April 30th 05 01:29 PM
FIND DATA WITHIN DATA (V-OR-H LOOKUP/FIND/MATCH?) Jaladino Excel Worksheet Functions 0 February 22nd 05 11:22 PM


All times are GMT +1. The time now is 06:58 PM.

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"