2 x work sheet change????

R

rodw

I have these 2 codes and need them on the same worksheet but can ge
this to work without errors, what am i doing wrong

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
If LCase(Target.Value) = "internal" Then
Columns("A:IV").Hidden = False
Columns("G:I").Hidden = True
End If
If LCase(Target.Value) = "frontline" Then
Columns("A:IV").Hidden = False
Columns("J:K").Hidden = True
End If
End If
End Sub
[End Sub







Private prev As Variant


Private Sub Worksheet_Calculate()
Static init As Boolean
Dim v As Variant

Application.EnableEvents = False
On Error GoTo CleanUp

v = Me.Range("Z1").Value

If init And v <> prev Then
Sheets("Main").Cells(Rows.Count, "D"). _
End(xlUp).Offset(1, 0).Value = v
Sheets("Main").Cells(Rows.Count, "C"). _
End(xlUp).Offset(1, 0).Value = Now()

prev = v
ElseIf Not init Then
init = True
prev = Range("H5").Value
End If

CleanUp:
Application.EnableEvents = True
End Sub



Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$Z$1" Then Exit Sub



prev = Target.Value

'Sheets("Main").Cells(Rows.Count, "A"). _
'End(xlUp).Offset(1, 0).Value = prev
' Sheets("Main").Cells(Rows.Count, "C"). _
' End(xlUp).Offset(1, 0).Value = Range


' Sheets("Main").Cells(Rows.Count, "C"). _
' End(xlUp).Offset(1, 0).Value = Now()



End Sub
 
F

Frank abel

Hi
after removing the last ]end sub this works for me:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Me.Range("A1"), Target) Is
Nothing Then
If LCase(Target.Value) = "internal" Then
Columns("A:IV").Hidden = False
Columns("G:I").Hidden = True
End If
If LCase(Target.Value) = "frontline" Then
Columns("A:IV").Hidden = False
Columns("J:K").Hidden = True
End If
End If
End Sub
 
R

rodw

sorry that was a typing error, i have only 1 endsub

i still get errors

when it forces the worksheet change i get ambiguous nam
 

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