ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change several cells based upon the value of one cell (https://www.excelbanter.com/excel-programming/423624-change-several-cells-based-upon-value-one-cell.html)

punking315

change several cells based upon the value of one cell
 
using vba.... what's the best way to change several cells based upon the
value of one cell. I know to a seasoned programmer the following attempt is
laughable but bear with me, here is the code I'm wrestling with:

Public Sub worksheet_calculate(ByVal Target As Range)
If Range("select_type").Text = "gable" Then
Range("gableroofing_value").Value = Val(Range("L83"))
Else
If Range("select_type").Text = "saltbox" Then
Range("gableroofing_value").Value = ""

End If
End If
End Sub

Private Sub worksheet_calculate()

If Range("select_type").Text = "gable" Then
Range("saltboxroofing_value").Value = ""

Else
If Range("select_type").Text = "saltbox" Then
Range("saltboxroofing_value").Value = (Val(Cells(85, 12)) + Val(Cells(86,
12)))
Else
End If
End If

End Sub


Private Sub Worksheet_Change(ByVal Target As Range)

If Range("select_type").Text = "gable" Then
Range("saltboxroofing").Font.Color = RGB(255, 255, 255)
Else
If Range("select_type").Text = "saltbox" Then
Range("saltboxroofing").Font.Color = RGB(0, 0, 0)
Else
End If
End If
End Sub

Don Guillett

change several cells based upon the value of one cell
 
This was asked and answered in a previous post.

Private Sub Worksheet_change(ByVal Target As Range)
If Target.Address = Cells(5, 2).Address Then
With Range("saltboxroofing").Font
..Color = vbBlack
If UCase(Target) = "GABLE" Then .Color = vbWhite
End With
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"punking315" wrote in message
...
using vba.... what's the best way to change several cells based upon the
value of one cell. I know to a seasoned programmer the following attempt
is
laughable but bear with me, here is the code I'm wrestling with:

Public Sub worksheet_calculate(ByVal Target As Range)
If Range("select_type").Text = "gable" Then
Range("gableroofing_value").Value = Val(Range("L83"))
Else
If Range("select_type").Text = "saltbox" Then
Range("gableroofing_value").Value = ""

End If
End If
End Sub

Private Sub worksheet_calculate()

If Range("select_type").Text = "gable" Then
Range("saltboxroofing_value").Value = ""

Else
If Range("select_type").Text = "saltbox" Then
Range("saltboxroofing_value").Value = (Val(Cells(85, 12)) + Val(Cells(86,
12)))
Else
End If
End If

End Sub


Private Sub Worksheet_Change(ByVal Target As Range)

If Range("select_type").Text = "gable" Then
Range("saltboxroofing").Font.Color = RGB(255, 255, 255)
Else
If Range("select_type").Text = "saltbox" Then
Range("saltboxroofing").Font.Color = RGB(0, 0, 0)
Else
End If
End If
End Sub



punking315

change several cells based upon the value of one cell
 
thanks for the nonsense

"Don Guillett" wrote:

This was asked and answered in a previous post.

Private Sub Worksheet_change(ByVal Target As Range)
If Target.Address = Cells(5, 2).Address Then
With Range("saltboxroofing").Font
..Color = vbBlack
If UCase(Target) = "GABLE" Then .Color = vbWhite
End With
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"punking315" wrote in message
...
using vba.... what's the best way to change several cells based upon the
value of one cell. I know to a seasoned programmer the following attempt
is
laughable but bear with me, here is the code I'm wrestling with:

Public Sub worksheet_calculate(ByVal Target As Range)
If Range("select_type").Text = "gable" Then
Range("gableroofing_value").Value = Val(Range("L83"))
Else
If Range("select_type").Text = "saltbox" Then
Range("gableroofing_value").Value = ""

End If
End If
End Sub

Private Sub worksheet_calculate()

If Range("select_type").Text = "gable" Then
Range("saltboxroofing_value").Value = ""

Else
If Range("select_type").Text = "saltbox" Then
Range("saltboxroofing_value").Value = (Val(Cells(85, 12)) + Val(Cells(86,
12)))
Else
End If
End If

End Sub


Private Sub Worksheet_Change(ByVal Target As Range)

If Range("select_type").Text = "gable" Then
Range("saltboxroofing").Font.Color = RGB(255, 255, 255)
Else
If Range("select_type").Text = "saltbox" Then
Range("saltboxroofing").Font.Color = RGB(0, 0, 0)
Else
End If
End If
End Sub





All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com