what is wrong with this macro code?

yichuansancun

Board Regular
Joined
Feb 7, 2011
Messages
123
What I try to achieve is that when the cell named housing_choice = "specified amount", excel should wipe out all the contents in the range with name "housing_m", and if the cell named housing_choice = "m data" then the cell named "housing" should be empty

If Range("housing_choice").Value = "specified amount" Then
Range("housing_m").Select
Selection.Value = ""
ElseIf Range("housing_choice").Value = "m data" Then
Range("housing").Select
Selection.Value = ""
End If


but it won't work... any ideas?

Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Thanks Peter, the reference setting of mine and my colleague's are exactly the same, yet the error only happens on her end, not mine.

I removed LCase in the code, and it seems to work properly now. LCase is to make the case insensitive for the value in the range "education_selection", correct?


Sub Goalseek123()

Application.EnableEvents = False

If LCase(Range("education_selection").Value) Like "*mercer data*" Then
Range("education").ClearContents
End If

If LCase(Range("choice").Value) Like "*specified amount*" Then
Range("housing_selection").ClearContents
ElseIf LCase(Range("choice").Value) Like "*mercer data*" Then
Range("housing").ClearContents
End If

Range("net_income").Select
Range("net_income").Goalseek Goal:=Range("net_income_value").Value, ChangingCell:=Range("gross_income")

Application.EnableEvents = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,223
Members
453,152
Latest member
ChrisMd

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