LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Use of Cell Values Instead of Hard Coding

I am using Excel 2003 and want to make my code as generic as possible.

I am very junior with this but I know proper coding is ...

Dim MstrInvList As Workbook
Dim AllInvSht As Worksheet

Set MstrInvList = Workbooks("Invoices & Work Estimates.xls")
MstrInvList.Activate
Set AllInvSht = Worksheets("Invoices & Work Estimates")
AllInvSht.Activate

But I would like something like this...
where cell S2 contains "Invoices & Work Estimates"
and cell R2 contains "Invoices & Work Estimates.xls"

The SET lines below fail. Is there a way around this? Can cell values used
in place of hard coding the workbook, worksheet names, etc?

Dim MstrInvList As Workbook
Dim AllInvSht As Worksheet

WBook = Range("S2")
WSheet = Range("R2")

Set MstrInvList = Workbooks("WBook")
MstrInvList.Activate
Set AllInvSht = Worksheets("WSheet")
AllInvSht.Activate

Others that I need to consider are working with these others...
Set DestWB = Workbooks.Open("E:\Directory1\TempWorkSheet.xls")
Set SourceRange = ThisWorkbook.Sheets("Fun With Excel").Range("K8:W8")
Set DestSh = DestWB.Worksheets("Invoices & Work Estimates")


Any and all help would be appreciated. Thanks in advance!
 
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 you instantiate classes without hard-coding class names?? ALittle Excel Programming 2 November 24th 05 01:59 AM
hard coding a cell darrelly Excel Discussion (Misc queries) 2 October 7th 05 11:24 PM
User-changeable paths into Excel - avoid hard coding gearoi[_3_] Excel Programming 11 August 31st 05 03:10 PM
Hard-Coding a File Location ibeetb Excel Programming 1 April 15th 04 06:46 PM


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