I created a code so that each time a record was inserted into a line the program would detect the last line with values (assigned to the variable "k") and select a specific interval for the graph to update, but an error occurs, could someone help me ?
VBA Code:
Public Sub Chart_Update()
Dim k As Long
k = Cells(Rows.Count, "B").End(xlUp).Row
Error
------------------------------------------------------------------
Range("B2:B&k,E2:E&k,I2:I&k,J2:J&k,K2:K&k").Select
--------------------------------------------------------------
ActiveChart.SetSourceData Source:=Range( _
"AC_Offset_Registers!$B$2:$B$&k,AC_Offset_Registers!$E$2:$E$&k,AC_Offset_Registers!$I$2:$I$&k,AC_Offset_Registers!$J$2:$J$&k,AC_Offset_Registers!$K$2:$K$&k" _
)
End Sub
Error:
VBA Code:
Public Sub Chart_Update()
Dim k As Long
k = Cells(Rows.Count, "B").End(xlUp).Row
Error
------------------------------------------------------------------
Range("B2:B&k,E2:E&k,I2:I&k,J2:J&k,K2:K&k").Select
--------------------------------------------------------------
ActiveChart.SetSourceData Source:=Range( _
"AC_Offset_Registers!$B$2:$B$&k,AC_Offset_Registers!$E$2:$E$&k,AC_Offset_Registers!$I$2:$I$&k,AC_Offset_Registers!$J$2:$J$&k,AC_Offset_Registers!$K$2:$K$&k" _
)
End Sub
Error: