Hopefully easy macro question

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

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
 
You can do

Select Case shtInput.Range("RiskT")

Case "FIXED": Module3.SetPagesFixed

Case "VARIABLE": Module3.SetPagesVariable
End Select
 
Application.Run "Module3.SetPages" & shtInput.Range("RiskT").value
 
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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top