Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Name a Table relative references

HI,

I'm trying to name a table using vba and
using relative references.
When we create the file from the database, the table change size.
The macro I have right now do many changes in the table
then, name the table to be use later in the macro for a Pivot Table
I save this macro in Personnal Macro

My problem
The macro always name the table using the same size.
How to create a macro using relative reference.
Rules:
The table always start at cell A4
Column A always have data
The table always stop at column J
Sometimes the last cell in column J do not have data.

Here what I tried the last time
I extract only the parts to name the table.


Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
ActiveWorkbook.Names.Add Name:="HvacTable", RefersToR1C1:= _
"=Sheet1!R4C1:R55C12"
ActiveCell.Select


Thanks
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Name a Table relative references

Thank you very much.
I tried different things and nothing was working with my files.
You just write the good one for me.
Thanks to you and all others.
I am not sure however I think the others formulas didn't work because in
cell A1,A2 was not empty.
For sure I will use your formula for others files.
Thanks again

"Don Guillett" wrote:

Also, notice I left out the space in the name

Sub setvarnamerng()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
Range("a4:J" & lr).Name = "HvacTable"
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mouimet" wrote in message
...
HI,

I'm trying to name a table using vba and
using relative references.
When we create the file from the database, the table change size.
The macro I have right now do many changes in the table
then, name the table to be use later in the macro for a Pivot Table
I save this macro in Personnal Macro

My problem
The macro always name the table using the same size.
How to create a macro using relative reference.
Rules:
The table always start at cell A4
Column A always have data
The table always stop at column J
Sometimes the last cell in column J do not have data.

Here what I tried the last time
I extract only the parts to name the table.


Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
ActiveWorkbook.Names.Add Name:="HvacTable", RefersToR1C1:= _
"=Sheet1!R4C1:R55C12"
ActiveCell.Select


Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Name a Table relative references

Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mouimet" wrote in message
...
Thank you very much.
I tried different things and nothing was working with my files.
You just write the good one for me.
Thanks to you and all others.
I am not sure however I think the others formulas didn't work because in
cell A1,A2 was not empty.
For sure I will use your formula for others files.
Thanks again

"Don Guillett" wrote:

Also, notice I left out the space in the name

Sub setvarnamerng()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
Range("a4:J" & lr).Name = "HvacTable"
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mouimet" wrote in message
...
HI,

I'm trying to name a table using vba and
using relative references.
When we create the file from the database, the table change size.
The macro I have right now do many changes in the table
then, name the table to be use later in the macro for a Pivot Table
I save this macro in Personnal Macro

My problem
The macro always name the table using the same size.
How to create a macro using relative reference.
Rules:
The table always start at cell A4
Column A always have data
The table always stop at column J
Sometimes the last cell in column J do not have data.

Here what I tried the last time
I extract only the parts to name the table.


Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
ActiveWorkbook.Names.Add Name:="HvacTable", RefersToR1C1:= _
"=Sheet1!R4C1:R55C12"
ActiveCell.Select


Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Name a Table relative references

Check your other post, too.

Mouimet wrote:

HI,

I'm trying to name a table using vba and
using relative references.
When we create the file from the database, the table change size.
The macro I have right now do many changes in the table
then, name the table to be use later in the macro for a Pivot Table
I save this macro in Personnal Macro

My problem
The macro always name the table using the same size.
How to create a macro using relative reference.
Rules:
The table always start at cell A4
Column A always have data
The table always stop at column J
Sometimes the last cell in column J do not have data.

Here what I tried the last time
I extract only the parts to name the table.

Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
ActiveWorkbook.Names.Add Name:="HvacTable", RefersToR1C1:= _
"=Sheet1!R4C1:R55C12"
ActiveCell.Select

Thanks


--

Dave Peterson


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
relative references Rob Excel Discussion (Misc queries) 2 December 6th 08 08:10 PM
convert relative cell references to absolute cell references via amacro? Dave F[_2_] Excel Discussion (Misc queries) 1 May 15th 08 04:43 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
Pivot Table Relative References Jimmy Excel Programming 2 September 4th 06 04:56 PM
Relative references for condtional formatting within a Pivot Table Matt X Excel Worksheet Functions 0 July 18th 06 07:42 PM


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