M
Morgan
hi, i was given the VB code below which takes all the value of cells V17 and
X25 and create a list down columns A and K on the 'graphs' sheet, it works
when i manually enter values into cells V17 and X25 and was testing it, but
it doesn't work when those cells are auto populated with data as they
calculate other cells, so the VB code isn't taking the values that appear in
those cells automatically like it should.
any ideas?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strColumn As String, lngRow As Long, ws As Worksheet
If Target.Count <> 1 Or Target.Text = "" Then Exit Sub
If Target.Address = "$V$17" Then
strColumn = "A"
ElseIf Target.Address = "$X$25" Then
strColumn = "K"
End If
If strColumn <> vbNullString Then
Set ws = Worksheets("graphs")
Application.EnableEvents = False
lngRow = ws.Cells(Rows.Count, strColumn).End(xlUp).Row
ws.Range(strColumn & lngRow + 1) = Target.Text
Application.EnableEvents = True
End If
End Sub
X25 and create a list down columns A and K on the 'graphs' sheet, it works
when i manually enter values into cells V17 and X25 and was testing it, but
it doesn't work when those cells are auto populated with data as they
calculate other cells, so the VB code isn't taking the values that appear in
those cells automatically like it should.
any ideas?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strColumn As String, lngRow As Long, ws As Worksheet
If Target.Count <> 1 Or Target.Text = "" Then Exit Sub
If Target.Address = "$V$17" Then
strColumn = "A"
ElseIf Target.Address = "$X$25" Then
strColumn = "K"
End If
If strColumn <> vbNullString Then
Set ws = Worksheets("graphs")
Application.EnableEvents = False
lngRow = ws.Cells(Rows.Count, strColumn).End(xlUp).Row
ws.Range(strColumn & lngRow + 1) = Target.Text
Application.EnableEvents = True
End If
End Sub