Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Open specific sheet depending on cell contents

Hi,

I'm fairly new to VB and need to create a macro which will open another
workbook and more specifically a sheet within it depending on its
contents.

I'll try to be a bit clearer. Say cell "A1" contained the name of the
sheet in another workbook, can I get a macro to read the contents of
"A1" and open that specific sheet?

As I said I'm fairly new to this, so the actual code to do it would
excellent.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Open specific sheet depending on cell contents

The macro recorder is your friend. I just recorded this and then modified.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/2/2006 by Don Guillett
'

'
'Workbooks.Open Filename:="C:\yourfolder\yourfilename.xls"
Workbooks.Open Filename:="C:\yourfolder\" & Range("a1") & ".xls"
End Sub


--
Don Guillett
SalesAid Software

"monkey harry" wrote in message
oups.com...
Hi,

I'm fairly new to VB and need to create a macro which will open another
workbook and more specifically a sheet within it depending on its
contents.

I'll try to be a bit clearer. Say cell "A1" contained the name of the
sheet in another workbook, can I get a macro to read the contents of
"A1" and open that specific sheet?

As I said I'm fairly new to this, so the actual code to do it would
excellent.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Open specific sheet depending on cell contents

Hi,

supposing that cell A1 contains path and filename (like "c:\test.xls").
you can use this code

sub OpenFile()
workbooks.open(range("a1").value)
end sub

To open the file "test.xls"
This is just basic code without error trapping.

Regards,
Ivan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Open specific sheet depending on cell contents

Thanks

That's helped a lot!!!

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 insert a picture depending on the contents of another cell? JP Excel Discussion (Misc queries) 1 May 11th 10 11:06 AM
Copy cell contents depending on font colour alistew Excel Worksheet Functions 0 May 11th 09 04:22 PM
Rename active sheet to contents of specific cell burl_rfc Excel Programming 3 February 28th 06 11:34 PM
Change the colour of a row depending on the contents of a date cell [email protected] Excel Programming 4 January 17th 06 10:27 PM
How do I change a buttons contents depending on a cells contents? Kosh42|EFG Excel Programming 2 February 16th 05 02:39 PM


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