PC Review


Reply
Thread Tools Rate Thread

Declaring a tab name as a variable

 
 
=?Utf-8?B?dGltbXVsbGE=?=
Guest
Posts: n/a
 
      25th Jan 2007
Can anyone help me adjust the following code to work properly. I'm getting
errors with the TabName variable. I'm trying to set the variable to the tab
name of the file that will be opened.

Sub FormatFiles()

Dim TabNAME As String
Dim WB As Workbook
Do
Set WB = Workbooks.Open(Filename:=ActiveCell)
Set TabName = ActiveSheet.Name

My Macro code - (This will be my own simple code to format the WB
workbook that was just opened)

Workbooks("Master file").Activate
Sheets("TabNAME").Range("B5:B102").FormulaR1C1 .... (This formula is a
vlookup formula the WB file.)


WB.Close True 'Save Changes
ActiveCell.Offset(1).Select
Loop Until ActiveCell = ""
End Sub


Any help would be appreciated
--
Regards,

timmulla
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      25th Jan 2007
"Set" is used for objects only.
Change Set TabName = ActiveSheet.Name
-to-
TabName = ActiveSheet.Name
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"timmulla" <(E-Mail Removed)>
wrote in message
Can anyone help me adjust the following code to work properly. I'm getting
errors with the TabName variable. I'm trying to set the variable to the tab
name of the file that will be opened.

Sub FormatFiles()
Dim TabNAME As String
Dim WB As Workbook
Do
Set WB = Workbooks.Open(Filename:=ActiveCell)
Set TabName = ActiveSheet.Name

My Macro code - (This will be my own simple code to format the WB
workbook that was just opened)

Workbooks("Master file").Activate
Sheets("TabNAME").Range("B5:B102").FormulaR1C1 .... (This formula is a
vlookup formula the WB file.)

WB.Close True 'Save Changes
ActiveCell.Offset(1).Select
Loop Until ActiveCell = ""
End Sub


Any help would be appreciated
--
Regards,
timmulla
 
Reply With Quote
 
=?Utf-8?B?Sk5X?=
Guest
Posts: n/a
 
      25th Jan 2007
You also need to remove the quotation marks from your variable when it is
used as a sheet name.

i.e. Sheets(TabNAME).Range("B5:B102").FormulaR1C1
--
JNW


"Jim Cone" wrote:

> "Set" is used for objects only.
> Change Set TabName = ActiveSheet.Name
> -to-
> TabName = ActiveSheet.Name
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
>
>
>
> "timmulla" <(E-Mail Removed)>
> wrote in message
> Can anyone help me adjust the following code to work properly. I'm getting
> errors with the TabName variable. I'm trying to set the variable to the tab
> name of the file that will be opened.
>
> Sub FormatFiles()
> Dim TabNAME As String
> Dim WB As Workbook
> Do
> Set WB = Workbooks.Open(Filename:=ActiveCell)
> Set TabName = ActiveSheet.Name
>
> My Macro code - (This will be my own simple code to format the WB
> workbook that was just opened)
>
> Workbooks("Master file").Activate
> Sheets("TabNAME").Range("B5:B102").FormulaR1C1 .... (This formula is a
> vlookup formula the WB file.)
>
> WB.Close True 'Save Changes
> ActiveCell.Offset(1).Select
> Loop Until ActiveCell = ""
> End Sub
>
>
> Any help would be appreciated
> --
> Regards,
> timmulla
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring a variable mcescher Microsoft Access VBA Modules 7 2nd Sep 2008 09:28 PM
Re: declaring variable Göran Andersson Microsoft C# .NET 0 14th Jun 2008 12:04 AM
Declaring a Variable =?Utf-8?B?R2FyeSBEb2xsaXZlcg==?= Microsoft Access Form Coding 3 18th Sep 2007 02:26 PM
re: Declaring A Variable Gordon Durgha Microsoft VB .NET 1 16th Mar 2004 07:12 AM
Declaring a variable? pgoodale Microsoft Excel Programming 2 2nd Jan 2004 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:35 PM.