Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 133
Default automatically deleting data, using macros

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?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default automatically deleting data, using macros

Do you mean...

Range("F6").Clearcontents
Range("F15").Clearcontents

If this post helps click Yes
---------------
Jacob Skaria


"Derrick" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default automatically deleting data, using macros

You can continue using your If statement. If only one crtieria, you could
just use "Else", or you can nest more If statements if needed. To delete
data, try:

Range("F6").ClearContents

Possible new macro:

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
Else
Range("F6").ClearContents
end if
end if
end sub

--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Derrick" wrote:

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?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default automatically deleting data, using macros

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
"Derrick" wrote:

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?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 133
Default automatically deleting data, using macros

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

"Jacob Skaria" wrote:

Do you mean...

Range("F6").Clearcontents
Range("F15").Clearcontents

If this post helps click Yes
---------------
Jacob Skaria


"Derrick" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically deleting macros David New Users to Excel 3 November 14th 08 05:14 PM
Deleting macros Mindy Excel Worksheet Functions 4 June 23rd 06 07:48 PM
Deleting Macros mattflow Excel Discussion (Misc queries) 3 August 23rd 05 07:29 PM
How can I make cell data automatically shift up when deleting Orangepegs Excel Discussion (Misc queries) 4 February 26th 05 11:11 PM
How can I make cell data automatically shift up when deleting... Orangepegs Excel Worksheet Functions 1 February 26th 05 04:17 AM


All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"