ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hopefully easy macro question (https://www.excelbanter.com/excel-programming/413862-hopefully-easy-macro-question.html)

Brad

Hopefully easy macro question
 
Can

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
End If
If UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

This be condensed to one line - something like?

Module3.SetPages & shtInput.Range("RiskT").value


--
Wag more, bark less

Bob Phillips[_3_]

Hopefully easy macro question
 
You can do

Select Case shtInput.Range("RiskT")

Case "FIXED": Module3.SetPagesFixed

Case "VARIABLE": Module3.SetPagesVariable
End Select


--
__________________________________
HTH

Bob

"Brad" wrote in message
...
Can

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
End If
If UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

This be condensed to one line - something like?

Module3.SetPages & shtInput.Range("RiskT").value


--
Wag more, bark less




Tom Ogilvy

Hopefully easy macro question
 
Application.Run "Module3.SetPages" & shtInput.Range("RiskT").value

--
Regards,
Tom Ogilvy


"Brad" wrote:

Can

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
End If
If UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

This be condensed to one line - something like?

Module3.SetPages & shtInput.Range("RiskT").value


--
Wag more, bark less


Dave Peterson

Hopefully easy macro question
 
You could condense it like:

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
elseIf UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

Or if those are the only two options that could be in RiskT:

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
else
Module3.SetPagesVariable
End If

or you could use Select Case if you want to support lots of options:

select case UCase(shtInput.Range("RiskT"))
case is = "FIXED" : Module3.SetPagesFixed
case is = "VARIABLE" : Module3.SetPagesVariable
End If

I'd use one of these before I'd use this--but this is valid:

application.run "Module3.SetPages" & shtInput.Range("RiskT")








Brad wrote:

Can

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
End If
If UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

This be condensed to one line - something like?

Module3.SetPages & shtInput.Range("RiskT").value

--
Wag more, bark less


--

Dave Peterson

Brad

Hopefully easy macro question
 
Thanks to all - I will be using the select case logic
--
Wag more, bark less


"Dave Peterson" wrote:

You could condense it like:

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
elseIf UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

Or if those are the only two options that could be in RiskT:

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
else
Module3.SetPagesVariable
End If

or you could use Select Case if you want to support lots of options:

select case UCase(shtInput.Range("RiskT"))
case is = "FIXED" : Module3.SetPagesFixed
case is = "VARIABLE" : Module3.SetPagesVariable
End If

I'd use one of these before I'd use this--but this is valid:

application.run "Module3.SetPages" & shtInput.Range("RiskT")








Brad wrote:

Can

If UCase(shtInput.Range("RiskT")) = "FIXED" Then
Module3.SetPagesFixed
End If
If UCase(shtInput.Range("RiskT")) = "VARIABLE" Then
Module3.SetPagesVariable
End If

This be condensed to one line - something like?

Module3.SetPages & shtInput.Range("RiskT").value

--
Wag more, bark less


--

Dave Peterson



All times are GMT +1. The time now is 05:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com