Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I find the cell/data the closest/nearest to another data? | Excel Worksheet Functions | |||
Find formatting doesn't work: "Excel cannot find data" | Excel Discussion (Misc queries) | |||
Despite data existing in Excel 2002 spreadsheet Find doesn't find | Excel Discussion (Misc queries) | |||
The match and lookup functions can find literal data but not the same data referenced from a cell | Excel Discussion (Misc queries) | |||
FIND DATA WITHIN DATA (V-OR-H LOOKUP/FIND/MATCH?) | Excel Worksheet Functions |