Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable cell in vba code


What I am trying to do is based on a cell in the MENU sheet B25
I want the blue hightlight in the cell to become the same.

Eg. IF B
B25 is July then the worksheet name will become July.

Is that possible?

Please help




Private Sub CommandButton7_Click()

Dim wbk As Workbook
Dim wks As Worksheet
Dim SrcBook As Workbook

Set SrcBook = ActiveWorkbook


Set wbk = Workbooks.Open("K:\Data.xls")
Set wks = wbk.Sheets("Sheet1")


Application.ScreenUpdating = False

SrcBook.Sheets("Transfer").UsedRange.Copy Destination:= _
wks.Range("B2")

wbk.Close (False)

Application.ScreenUpdating = True

End Su

--
Mikeic
-----------------------------------------------------------------------
Mikeice's Profile: http://www.excelforum.com/member.php...fo&userid=2246
View this thread: http://www.excelforum.com/showthread.php?threadid=39151

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable cell in vba code


Good morning Mikeice

Sorry, but I'm not quite sure what you're after here. Do you want to
rename the worksheet after the contents of a cell? If so, does this
piece of code help you at all:

a = Range("B25").Value
ActiveSheet.Name = a

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=391515

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable cell in vba code


HI There

thanks for your response.

What I need is the workbook I am copy to has 12 sheet names.
Jan - Dec

So based on the cell I need the appropraite sheet to be selected before
copy and pasting the worksheet contents.


--
Mikeice
------------------------------------------------------------------------
Mikeice's Profile: http://www.excelforum.com/member.php...o&userid=22467
View this thread: http://www.excelforum.com/showthread...hreadid=391515

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
can i link a variable cost code with a variable sum I need help!! Excel Discussion (Misc queries) 0 August 1st 08 11:40 AM
Variable within the code ngedwin Excel Programming 2 July 10th 05 10:31 AM
variable code?? Paul Excel Discussion (Misc queries) 1 April 5th 05 06:37 PM
variable code Paul Excel Programming 2 April 5th 05 05:27 PM
Variable in a VB Code Michael Kintner Excel Programming 1 January 5th 04 02:29 PM


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