Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default How do I use a cell value as a parameter

Hi, I have a value in a particular cell that I want to use to launch a
macro that will use that value. I am not an expert on VB, but I guess
this means I could use the cell as a parameter?

The best way to explain is probably by showing the macro:

Sheets("Jan 08").Visible = True
Selection.AutoFilter Field:=2, Criteria1:="Night"

The Jan 08 value could change everytime, dependant on what is in the
cell (say B2) so it may May 08, Dec 08 etc. I simply want the "Jan
08" to be "<cell B2" every time. Can anyone help please?

Cheers

Rich
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default How do I use a cell value as a parameter

Sub sheetvar()
Set myvar = Sheets(Sheets("sheet3").Range("b2").Value)
myvar.Visible = True
End Sub
However you do not have to make the sheet visible to do as desired

Sub FilterHiddenSheet()
Set myvar = Sheets(Sheets("sheet3").Range("e1").Value)
'myvar.Visible = True
myvar.Range("a1").AutoFilter Field:=1, Criteria1:=1
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Richhall" wrote in message
...
Hi, I have a value in a particular cell that I want to use to launch a
macro that will use that value. I am not an expert on VB, but I guess
this means I could use the cell as a parameter?

The best way to explain is probably by showing the macro:

Sheets("Jan 08").Visible = True
Selection.AutoFilter Field:=2, Criteria1:="Night"

The Jan 08 value could change everytime, dependant on what is in the
cell (say B2) so it may May 08, Dec 08 etc. I simply want the "Jan
08" to be "<cell B2" every time. Can anyone help please?

Cheers

Rich


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default How do I use a cell value as a parameter

When I posted, Chips answer was NOT visible to me

Server problems on my end, I think. The message sat in my OutBox for a long
time before making its way through the ether.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Don Guillett" wrote in message
...
When I posted, Chips answer was NOT visible to me

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
Sub sheetvar()
Set myvar = Sheets(Sheets("sheet3").Range("b2").Value)
myvar.Visible = True
End Sub
However you do not have to make the sheet visible to do as desired

Sub FilterHiddenSheet()
Set myvar = Sheets(Sheets("sheet3").Range("e1").Value)
'myvar.Visible = True
myvar.Range("a1").AutoFilter Field:=1, Criteria1:=1
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Richhall" wrote in message
...
Hi, I have a value in a particular cell that I want to use to launch a
macro that will use that value. I am not an expert on VB, but I guess
this means I could use the cell as a parameter?

The best way to explain is probably by showing the macro:

Sheets("Jan 08").Visible = True
Selection.AutoFilter Field:=2, Criteria1:="Night"

The Jan 08 value could change everytime, dependant on what is in the
cell (say B2) so it may May 08, Dec 08 etc. I simply want the "Jan
08" to be "<cell B2" every time. Can anyone help please?

Cheers

Rich




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default How do I use a cell value as a parameter

Rich,

You can use code like

Dim WS As Worksheet
Dim WSName As String
WSName = Worksheets("Sheet1").Range("B2").Value
Set WS = Worksheets(WSName)
WS.Select
WS.AutoFilter Field:=2, Criteria1:="Night"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"Richhall" wrote in message
...
Hi, I have a value in a particular cell that I want to use to launch a
macro that will use that value. I am not an expert on VB, but I guess
this means I could use the cell as a parameter?

The best way to explain is probably by showing the macro:

Sheets("Jan 08").Visible = True
Selection.AutoFilter Field:=2, Criteria1:="Night"

The Jan 08 value could change everytime, dependant on what is in the
cell (say B2) so it may May 08, Dec 08 etc. I simply want the "Jan
08" to be "<cell B2" every time. Can anyone help please?

Cheers

Rich




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default How do I use a cell value as a parameter

On Jan 6, 2:00*pm, "Chip Pearson" wrote:
Rich,

You can use code like

Dim WS As Worksheet
Dim WSName As String
WSName = Worksheets("Sheet1").Range("B2").Value
Set WS = Worksheets(WSName)
WS.Select
WS.AutoFilter Field:=2, Criteria1:="Night"

--
Cordially,
Chip Pearson
Microsoft MVP *- Excel, 10 Years
Pearson Software Consultingwww.cpearson.com
(email on the web site)

"Richhall" wrote in message

...



Hi, I have a value in a particular cell that I want to use to launch a
macro that will use that value. *I am not an expert on VB, but I guess
this means I could use the cell as a parameter?


The best way to explain is probably by showing the macro:


* *Sheets("Jan 08").Visible = True
* *Selection.AutoFilter Field:=2, Criteria1:="Night"


The Jan 08 value could change everytime, dependant on what is in the
cell (say B2) so it may May 08, Dec 08 etc. *I simply want the "Jan
08" to be "<cell B2" every time. Can anyone help please?


Cheers


Rich- Hide quoted text -


- Show quoted text -


Excellent, thank you both. Cheers, Rich
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
How do a set a parameter in cell - choose A or B options? cara8236 Excel Worksheet Functions 3 July 19th 07 04:53 PM
How to choose if I use a parameter or not in a parameter query Arnaud Excel Discussion (Misc queries) 0 March 8th 07 01:19 PM
how to pass a cell as parameter for an external program? maxbell Excel Discussion (Misc queries) 1 February 8th 07 10:40 AM
Parameter Query Cell substitution Jockel Excel Discussion (Misc queries) 2 December 8th 06 04:28 PM
Sort (parameter stored in cell) GerryK Excel Worksheet Functions 0 March 21st 06 06:41 PM


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