ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA macro to select a tab (https://www.excelbanter.com/excel-programming/417987-vba-macro-select-tab.html)

Eduardo

VBA macro to select a tab
 
Hi everybody, I hope you can help me with this one. I have a Pivot table
where I have a macro that update my invoicing information from an external
data. So every month I run that macro to have the sales of the previous
month. The month in the PV is in cell B14. In the same worksheet I have
different tabs for each month where I copy the information as values in order
to create a Summary of sales. What I need to do is once the macro is run and
the month show up in cell B14 is go to the corresponding tab i.e. Aug. Thank
you in advance

DMoney

VBA macro to select a tab
 
you can assign the value of cell B14 to a variable and use the variable to
select the appropriate tab.

dim tab as string
tab=range("b14").value
worksheets(tab).select


HTH

dmoney

"Eduardo" wrote:

Hi everybody, I hope you can help me with this one. I have a Pivot table
where I have a macro that update my invoicing information from an external
data. So every month I run that macro to have the sales of the previous
month. The month in the PV is in cell B14. In the same worksheet I have
different tabs for each month where I copy the information as values in order
to create a Summary of sales. What I need to do is once the macro is run and
the month show up in cell B14 is go to the corresponding tab i.e. Aug. Thank
you in advance


Eduardo

VBA macro to select a tab
 
Hi, dmoney, and thank you for the replay. I am getting a compile error. I am
using excel 2007

"dmoney" wrote:

you can assign the value of cell B14 to a variable and use the variable to
select the appropriate tab.

dim tab as string
tab=range("b14").value
worksheets(tab).select


HTH

dmoney

"Eduardo" wrote:

Hi everybody, I hope you can help me with this one. I have a Pivot table
where I have a macro that update my invoicing information from an external
data. So every month I run that macro to have the sales of the previous
month. The month in the PV is in cell B14. In the same worksheet I have
different tabs for each month where I copy the information as values in order
to create a Summary of sales. What I need to do is once the macro is run and
the month show up in cell B14 is go to the corresponding tab i.e. Aug. Thank
you in advance


Eduardo

VBA macro to select a tab
 
Hi Dmoney I figure out, just modify your code Thank you very much

Dim workbooktab As String
workbooktab = Range("b14").Value
Worksheets(workbooktab).Select

"dmoney" wrote:

you can assign the value of cell B14 to a variable and use the variable to
select the appropriate tab.

dim tab as string
tab=range("b14").value
worksheets(tab).select


HTH

dmoney

"Eduardo" wrote:

Hi everybody, I hope you can help me with this one. I have a Pivot table
where I have a macro that update my invoicing information from an external
data. So every month I run that macro to have the sales of the previous
month. The month in the PV is in cell B14. In the same worksheet I have
different tabs for each month where I copy the information as values in order
to create a Summary of sales. What I need to do is once the macro is run and
the month show up in cell B14 is go to the corresponding tab i.e. Aug. Thank
you in advance


Barb Reinhardt

VBA macro to select a tab
 
I bet when you got the compile error, you were running the code from another
worksheet besides the one with the value in B14.
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Eduardo" wrote:

Hi, dmoney, and thank you for the replay. I am getting a compile error. I am
using excel 2007

"dmoney" wrote:

you can assign the value of cell B14 to a variable and use the variable to
select the appropriate tab.

dim tab as string
tab=range("b14").value
worksheets(tab).select


HTH

dmoney

"Eduardo" wrote:

Hi everybody, I hope you can help me with this one. I have a Pivot table
where I have a macro that update my invoicing information from an external
data. So every month I run that macro to have the sales of the previous
month. The month in the PV is in cell B14. In the same worksheet I have
different tabs for each month where I copy the information as values in order
to create a Summary of sales. What I need to do is once the macro is run and
the month show up in cell B14 is go to the corresponding tab i.e. Aug. Thank
you in advance



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com