Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Change to Worksheet Change Event

Hello, given the worksheet change event code below:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
With Target
If .Column = 6 And .Row 11 And .Row < 112 Then
Application.EnableEvents = False
If .Value = "S" Then
Cells(.Row, 8).FormulaR1C1 =
"=IF(ISBLANK(RC[-3]),0,IF(RC[-3]=""FT"",R10C25*8,R10C25*4))"
Cells(.Row, 9).FormulaR1C1 = "=RC[-2]*RC[-1]"
End If
Application.EnableEvents = True
End If
End With
End Sub

How can I have the code NOT put a formula in, for exmple, Cells(.Row,8) if
that call is NOT blank? I only want the formula to be entered if the cell
is blank. Thanks for your help!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Change to Worksheet Change Event

This should do it if you mean "if the cell value is blank, even if the blank
is the result of a formula in the cell"
If Cells(.Row,8).Value="" Then Cells(.Row, 8).FormulaR1C1 =
"=IF(ISBLANK(RC[-3]),0,IF(RC[-3]=""FT"",R10C25*8,R10C25*4))"

This should do it if you mean that both the value of the cell is blank AND
there is no formula within the cell:
If Cells(.Row,8).Formula = "" Then Cells(.Row, 8).FormulaR1C1 =
"=IF(ISBLANK(RC[-3]),0,IF(RC[-3]=""FT"",R10C25*8,R10C25*4))"

--
- K Dales


"Steph" wrote:

Hello, given the worksheet change event code below:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
With Target
If .Column = 6 And .Row 11 And .Row < 112 Then
Application.EnableEvents = False
If .Value = "S" Then
Cells(.Row, 8).FormulaR1C1 =
"=IF(ISBLANK(RC[-3]),0,IF(RC[-3]=""FT"",R10C25*8,R10C25*4))"
Cells(.Row, 9).FormulaR1C1 = "=RC[-2]*RC[-1]"
End If
Application.EnableEvents = True
End If
End With
End Sub

How can I have the code NOT put a formula in, for exmple, Cells(.Row,8) if
that call is NOT blank? I only want the formula to be entered if the cell
is blank. Thanks for your help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Change to Worksheet Change Event

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
With Target
If .Column = 6 And .Row 11 And .Row < 112 Then
Application.EnableEvents = False
If .Value = "S" Then
if isempty(Cells(.row,8)) then
Cells(.Row, 8).FormulaR1C1 =
"=IF(ISBLANK(RC[-3]),0,IF(RC[-3]=""FT"",R10C25*8,R10C25*4))"
End if
if isempty(Cells(.Row,9)) then
Cells(.Row, 9).FormulaR1C1 = "=RC[-2]*RC[-1]"
End if
End If
Application.EnableEvents = True
End If
End With
End Sub

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hello, given the worksheet change event code below:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
With Target
If .Column = 6 And .Row 11 And .Row < 112 Then
Application.EnableEvents = False
If .Value = "S" Then
Cells(.Row, 8).FormulaR1C1 =
"=IF(ISBLANK(RC[-3]),0,IF(RC[-3]=""FT"",R10C25*8,R10C25*4))"
Cells(.Row, 9).FormulaR1C1 = "=RC[-2]*RC[-1]"
End If
Application.EnableEvents = True
End If
End With
End Sub

How can I have the code NOT put a formula in, for exmple, Cells(.Row,8) if
that call is NOT blank? I only want the formula to be entered if the cell
is blank. Thanks for your 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
Worksheet Change Event Steph[_6_] Excel Programming 5 October 18th 05 10:11 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
worksheet change event gautamvt Excel Programming 1 December 10th 03 05:15 PM
Worksheet Change Event Help Please J P Singh Excel Programming 1 July 16th 03 09:37 AM


All times are GMT +1. The time now is 02:14 AM.

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

About Us

"It's about Microsoft Excel"