automatically deleting data, using macros

D

Derrick

i have some code on the bottom of one of my sheets, something like this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B3")) Is Nothing Then Exit Sub
Rows("6:47").EntireRow.Hidden = False

If Range("B3") = "Standardized Module Width" Then
Rows("6:6").EntireRow.Hidden = False
:
Rows("15:15").EntireRow.Hidden = False
end if
end if
end sub
:
Im wondering if its possible to delete the information in cells, eg: F6,
F15, ... when another option is selected - so not Standardized module width
- i have 3 options...

can anyone help?
 
J

JLatham

For just 3 conditions, you could use
IF Range("B3")= "condition 1"
action
ElseIf Range("B3") = "condition 2"
action code
Else
3rd 'catch all' action
End If

Or if you think you may eventually have more than 3 conditions, using Select
Case could be a better option, as it's easier to modify later. The
UCase(Trim( will remove white space at beginning/end of B3, and convert all
to upper case for testing to take the worry out of case of value in B3.
Select Case UCase(Trim(Range("B3")))
Case Is = "CONDITION 1"
action code for condition 1
Case Is = "CONDITION 2"
action code for condition 2
Case Is = "CONDITION 3"
action code for condition 3
Case Else
'catch anything else code, this
'can actually be empty, i.e. do nothing
End Select

Hope this helps
 
D

Derrick

thanks,
Ive decided to use
Range("F6") = 0

and then i realized i had some formulas in there that were dependent on
another cell.. can i write the formulas into this somehow? ie

if(B3= "optionA",(if Width = TotalWidth,2,1),0)
where Width and totalWidth are pseudonames for cell blocks with the
width/total width in them

thanks
 

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

Top