简体   繁体   中英

Fill out cell in row range where active cell is then set active cell to the next row

I'm trying to create an automated Excel file in which it will copy a cell to another. I already did a timer in which it will start and stop. Once it stopped I can now copy it to a specific cell (for example J11), but what I need now is that every time I stop the timer it will copy the time to the next row (J12) and so on and so forth. So every time I stop the timer it will copy the value to the next rowcell.

Here's my code so far.

Dim Start As Single, RunTime As Single
Dim ElapsedTime As String



Range("A1").Value = 0
Range("K8").Value = "In Progress"
Range("K8").Interior.Color = 5296274

Start = Timer

Do While Range("A1").Value = 0

DoEvents
RunTime = Timer
ElapsedTime = Format((RunTime - Start) / 86400, "hh:mm:ss")
Range("C4").Value = ElapsedTime
Application.StatusBar = ElapsedTime

Loop

Range("C4").Value = ElapsedTime
Range("K8").Interior.Color = 192
Range("K8").Value = "Ended"
Application.StatusBar = False

Application.Wait DateAdd("s", 3, Now) ' wait for 3 seconds

Range("K8").Interior.Color = RGB(255, 255, 255)
Range("K8").Value = ""
Range("I5").Value = ""
Range("A1").Value = 0
Range("C4").Value = 0

Range("F8").Copy Range("E11")
Range("F9").Copy Range("F11") <---this is static, this is where I want it to be dynamic.

You can use the code below:

'Set Active Cell
 eRow = ActiveSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).Row


 Cells(eRow, 5).Value = Range("F8").Value
 Cells(eRow, 6).Value = Range("F9").Value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM