gauravkrgautam
Member
How could i change value of variable from one line to another, or say it should be calculate every time.
File is attached and the concerned variable is lastrow which is not updating its value even when i have mentioned it in the beginning of module. codi is :
[\code]
File is attached and the concerned variable is lastrow which is not updating its value even when i have mentioned it in the beginning of module. codi is :
Code:
Option Explicit
Dim lastrow As Double
Sub test()
Dim rng As Range
Sheets("week range").Activate
lastrow = ActiveSheet.Range("a" & ActiveSheet.Rows.Count).End(xlUp).Row
MsgBox lastrow
Range("a" & lastrow).Select
ActiveCell.Value = ActiveCell.Offset(0, 3)
ActiveCell.Offset(1, 0).Value = ActiveCell.Offset(0, 4)
Set rng = ActiveSheet.Range("a1:a" & lastrow)
MsgBox lastrow
End Sub
' How could i change value of variable from one line to another, or say it should be calculate every time _
Sub test1()
Dim rng As Range
Sheets("sheet2").Activate
lastrow = ActiveSheet.Range("a" & ActiveSheet.Rows.Count).End(xlUp).Row
MsgBox lastrow
Range("a" & lastrow).Select
ActiveCell.Value = ActiveCell.Offset(0, 3)
ActiveCell.Offset(1, 0).Value = ActiveCell.Offset(0, 4)
Set rng = ActiveSheet.Range("a1:a" & lastrow)
MsgBox lastrow
End Sub
Attachments
Last edited: