What is wrong with my code?

Finance20

New Member
Joined
Aug 19, 2011
Messages
8
Sub Multiplier()
'
'Muttiplier Number Format by MEI given FYE & Clinic Type
'
'
Workbooks("RL-Facility Charge Lookup 1-7-2011 2010.xls").Activate
Worksheets("Facility Lookup").Activate
Range("F11:F14").Activate
If Range(A6) = "RHCP" Or "RHCI" And Range(B4) = "2005" Then
Range("F11:F14").Value = (1.029 * 0.25) + (1.031 * 0.75)


End If
End Sub

I am getting error in debugger on Lines beginning with: If Range
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try this:

If (Range("A6").Value = "RHCP" Or Range("A6").Value = "RHCI") And Range("B4").Value = "2005" Then
 
Upvote 0
Finance20,

When doing multiple conditions in an IF statement, each condition needs tobe explicitly stated as if the other statements aren't there. Also, Range(A6) isn't valid becuase that's trying to reference a variable named A6. To avoid that, surround the cell address in quotes - Range("A6"). That being said, try the following:
Code:
Sub Multiplier()
    
    With Workbooks("RL-Facility Charge Lookup 1-7-2011 2010.xls").Sheets("Facility Lookup")
        If .Range("A6").Value = "RHCP" _
        Or .Range("A6").Value = "RHCI" _
        And .Range("B4").Value = "2005" Then
            .Range("F11:F14").Value = 1.0305
        End If
    End With
    
End Sub



Hope that helps,
~tigeravatar
 
Upvote 0
Maybe

Code:
If (Range("A6").Value = "RHCP" Or Range("A6").Value = "RHCI") And Range("B4").Value = "2005" Then
Range("F11:F14").Value = Evaluate("(1.029 * 0.25) + (1.031 * 0.75)")
 
Upvote 0
Then try

Code:
If (Range("A6").Value = "RHCP" Or Range("A6").Value = "RHCI") And Range("B4").Value = 2005 Then
Range("F11:F14").Value = 1.0305
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top