Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default variable consolidation ending tab name

Hi all,

I am trying to figure out how to substitute the ending tab name used in the
sum consolidation formula, e.g. =SUM('04:03'!C46), where tab name "03" need
to be changed according to selection, INDIRECT function seems not working
here, please help! Thanks a lot,

Seaq
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default variable consolidation ending tab name

Sorry this thread appeared twice as I got error posting reply from the screen

"according to selection" means I wish to input value in another cell so as
to quickly change the ending tab name

at this stage, I am replacing it manually,

Regards,


"Seaq" wrote:

Hi all,

I am trying to figure out how to substitute the ending tab name used in the
sum consolidation formula, e.g. =SUM('04:03'!C46), where tab name "03" need
to be changed according to selection, INDIRECT function seems not working
here, please help! Thanks a lot,

Seaq

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default variable consolidation ending tab name

I don't believe indirect can be used this way, I think you will need to
resort to VBA code. I presume you mean by "according to a selection" that
you have a drop down list somewhere, lets say C1. And you want the formula
to be in C2 of Sheet1.

Add the following code to the Sheet1 object in the VB editor:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, [C1])
If Not isect Is Nothing Then
[C2] = "=SUM(Sheet2:" & Target & "!A1)"
End If
End Sub



1. To add this code to your file, press Alt+F11,
2. In the VBAProject window, top left side, find your sheet name under your
file name and double click it.
3. Paste in or type the code above.
--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Seaq" wrote:

Hi all,

I am trying to figure out how to substitute the ending tab name used in the
sum consolidation formula, e.g. =SUM('04:03'!C46), where tab name "03" need
to be changed according to selection, INDIRECT function seems not working
here, please help! Thanks a lot,

Seaq

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Thanks

Thanks Shane.

As a VBA newbie so I pasted in the code and replaced the [c1] with my drop
down list cell, an error message replies " object required" for line Set
isect = Application.Intersect(Target, G1)? can you help?
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Thanks

From workbook, right click on the sheet tab View Code and paste the code
which Shane provided..and then try.

Remove the code from

If this post helps click Yes
---------------
Jacob Skaria


"Seaq" wrote:

Thanks Shane.

As a VBA newbie so I pasted in the code and replaced the [c1] with my drop
down list cell, an error message replies " object required" for line Set
isect = Application.Intersect(Target, G1)? can you help?



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Thanks

Actually I know where to paste the code to, i have modified the cell address
to suit my example as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, G1)
If Not isect Is Nothing Then
b6 = "=SUM(Sheet1:" & Target & "!A1)"
End If
End Sub

in th WB cell "G1", a drop down list (sheet2, sheet3,sheet4,sheet5) is made

in the WB cell "B6", keep it blank

and saved the WB, reopen it with macro enabled

When selecting from the drop down list, the error message goes as "object
required"

How should I solve this?


"Jacob Skaria" wrote:

From workbook, right click on the sheet tab View Code and paste the code
which Shane provided..and then try.

Remove the code from

If this post helps click Yes
---------------
Jacob Skaria


"Seaq" wrote:

Thanks Shane.

As a VBA newbie so I pasted in the code and replaced the [c1] with my drop
down list cell, an error message replies " object required" for line Set
isect = Application.Intersect(Target, G1)? can you help?

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Thanks

Right click the sheet tab. View Code and paste the below....Try and feedback

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("G1")) Is Nothing Then
Application.EnableEvents = False
Range("B6") = "=SUM(Sheet1:" & Target & "!A1)"
Application.EnableEvents = True
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Seaq" wrote:

Actually I know where to paste the code to, i have modified the cell address
to suit my example as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, G1)
If Not isect Is Nothing Then
b6 = "=SUM(Sheet1:" & Target & "!A1)"
End If
End Sub

in th WB cell "G1", a drop down list (sheet2, sheet3,sheet4,sheet5) is made

in the WB cell "B6", keep it blank

and saved the WB, reopen it with macro enabled

When selecting from the drop down list, the error message goes as "object
required"

How should I solve this?


"Jacob Skaria" wrote:

From workbook, right click on the sheet tab View Code and paste the code
which Shane provided..and then try.

Remove the code from

If this post helps click Yes
---------------
Jacob Skaria


"Seaq" wrote:

Thanks Shane.

As a VBA newbie so I pasted in the code and replaced the [c1] with my drop
down list cell, an error message replies " object required" for line Set
isect = Application.Intersect(Target, G1)? can you help?

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Thanks

Great, it works.

Thanks a lot.

BTW, in case when I deleted the B6 cell formula (on the WB which is brought
by the code automatically) by accident, it does NOT seem to reinstall again,
what shall I do then?

Regards,

"Jacob Skaria" wrote:

Right click the sheet tab. View Code and paste the below....Try and feedback

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("G1")) Is Nothing Then
Application.EnableEvents = False
Range("B6") = "=SUM(Sheet1:" & Target & "!A1)"
Application.EnableEvents = True
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Seaq" wrote:

Actually I know where to paste the code to, i have modified the cell address
to suit my example as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, G1)
If Not isect Is Nothing Then
b6 = "=SUM(Sheet1:" & Target & "!A1)"
End If
End Sub

in th WB cell "G1", a drop down list (sheet2, sheet3,sheet4,sheet5) is made

in the WB cell "B6", keep it blank

and saved the WB, reopen it with macro enabled

When selecting from the drop down list, the error message goes as "object
required"

How should I solve this?


"Jacob Skaria" wrote:

From workbook, right click on the sheet tab View Code and paste the code
which Shane provided..and then try.

Remove the code from

If this post helps click Yes
---------------
Jacob Skaria


"Seaq" wrote:

Thanks Shane.

As a VBA newbie so I pasted in the code and replaced the [c1] with my drop
down list cell, an error message replies " object required" for line Set
isect = Application.Intersect(Target, G1)? can you help?

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
consolidation sum where ending tab value is changeable Seaq Excel Worksheet Functions 5 June 3rd 09 06:47 AM
Ending another applicatoni Brettjg Excel Discussion (Misc queries) 0 March 3rd 08 12:01 AM
Ending a Sheet nabanco Excel Worksheet Functions 2 June 24th 07 01:23 AM
Ending zero RAB Excel Discussion (Misc queries) 3 August 25th 05 06:09 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


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