Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Automatically Determine last row and column

Paul

Dim lrow As Long, lcol as Long

lrow = Cells(Rows.COUNT, "A").End(xlUp).Row
' change to what ever column you want.

lcol = ActiveSheet.Range("IV1").End(xlToLeft).Column
' change to what ever row you want

--
sb
"Paul Hastings" wrote in message
...
Hi -

I am trying to automatically generate a Pivot Table from data that has

been
pulled into a worksheet from a database. The data always starts in R1C1,

but
the extent is variable. Here is an example:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"SP1a!R1C1:R6897C21").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1"

Its the "R6897C21" part I want to fix. How can I determine the last row

and
column that has data in it so I can change this based on my actual data?

Thanks,

Paul Hastings
Principal Computer Scientist
Jorge Scientific Corporation
104 Park Drive
Warner Robins, GA 31088
(478) 923-2662 x122




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Automatically Determine last row and column

Paul,

lrow determines the row number of the last entry in column A regardless of
any gaps in the data. You can choose any column you want to represent your
data.

lcol determines the column number of the last entry in row 1 regardless of
any gaps in the data. You can choose any row you want to represent your
data.

Than in your formula
add (just for clarity)
Dim rng as String
rng = "SP1a!R1C1:R" & lrow & "C" & lcol & ")"

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=rng.CreatePivotTable TableDestination:="",

double check the "s and )
I wasn't sure if I got them right.

--
sb
"Paul Hastings" wrote in message
...
Steve -

I am not sure what this does. I am looking for the last row and column

that
have data in them. Then I want to convert that to rowcolumn format, e.g.
R1C1:R623C21. How would you go about that?

Thanks,

Paul
"steve" wrote in message
...
Paul

Dim lrow As Long, lcol as Long

lrow = Cells(Rows.COUNT, "A").End(xlUp).Row
' change to what ever column you want.

lcol = ActiveSheet.Range("IV1").End(xlToLeft).Column
' change to what ever row you want

--
sb
"Paul Hastings" wrote in message
...
Hi -

I am trying to automatically generate a Pivot Table from data that has

been
pulled into a worksheet from a database. The data always starts in

R1C1,
but
the extent is variable. Here is an example:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,

SourceData:=
_
"SP1a!R1C1:R6897C21").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1"

Its the "R6897C21" part I want to fix. How can I determine the last

row
and
column that has data in it so I can change this based on my actual

data?

Thanks,

Paul Hastings
Principal Computer Scientist
Jorge Scientific Corporation
104 Park Drive
Warner Robins, GA 31088
(478) 923-2662 x122








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically Determine last row and column

Steve -

I get it. Took a while for the cobwebs to clear, but I got it. Very nice.

Thanks,

Paul


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Automatically Determine last row and column

Paul,

You're welcome! I use this all the time.

I also use defined names that will self-adjust and reference the name rather
than the range. (don't know how to adjust for column in the name, but can
adjust for row). Saves a lot of headache.

Post back if you want more.

--
sb
"Paul Hastings" wrote in message
...
Steve -

I get it. Took a while for the cobwebs to clear, but I got it. Very nice.

Thanks,

Paul




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Automatically Determine last row and column

Steve,

Permission to email you? I have a situation similar to Paul's, with the
addition that the first row and column cell references are unknown.

Basically, if you have a modest sized table ANYWHERE on the worksheet, I
need to find the top-left cell reference and the bottom-right cell reference
for that table.

Thanks!

-gk-


"steve" wrote in message
...
Paul,

You're welcome! I use this all the time.

I also use defined names that will self-adjust and reference the name

rather
than the range. (don't know how to adjust for column in the name, but can
adjust for row). Saves a lot of headache.

Post back if you want more.

--
sb
"Paul Hastings" wrote in message
...
Steve -

I get it. Took a while for the cobwebs to clear, but I got it. Very

nice.

Thanks,

Paul








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Automatically Determine last row and column

TBA,

Fire away (no virus please).

Let me know how you get to the table.

You can start with this code. If the active cell is anywhere in the table

Dim msg As String
'
Selection.CurrentRegion.Select
msg = MsgBox(Selection.Address)

--
sb
"TBA" wrote in message
...
Steve,

Permission to email you? I have a situation similar to Paul's, with the
addition that the first row and column cell references are unknown.

Basically, if you have a modest sized table ANYWHERE on the worksheet, I
need to find the top-left cell reference and the bottom-right cell

reference
for that table.

Thanks!

-gk-


"steve" wrote in message
...
Paul,

You're welcome! I use this all the time.

I also use defined names that will self-adjust and reference the name

rather
than the range. (don't know how to adjust for column in the name, but

can
adjust for row). Saves a lot of headache.

Post back if you want more.

--
sb
"Paul Hastings" wrote in message
...
Steve -

I get it. Took a while for the cobwebs to clear, but I got it. Very

nice.

Thanks,

Paul








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
Determine a result of one column based on conditions in two column tel703 Excel Discussion (Misc queries) 1 March 25th 10 05:01 PM
How do I determine the last cell in a Column Ayo Excel Discussion (Misc queries) 6 April 27th 09 12:46 PM
Setting up an Excel sheet to automatically determine when an employeeshould enter a retirement plan, perhaps What-If Analysis would help? Anyother suggestions? Enda80 Links and Linking in Excel 0 December 21st 08 12:28 PM
Determine if Value in column A exists in Column B TJKarakowski Excel Discussion (Misc queries) 3 July 19th 05 06:27 PM
How do I determine automatically that a sheet is empty? [email protected] Excel Worksheet Functions 4 May 9th 05 08:15 PM


All times are GMT +1. The time now is 02:39 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"