PDA

View Full Version : Macro to auto copy a cell and paste it in a particular column



eakpan2012
10-15-2018, 09:30 AM
Macro to auto copy a cell and paste it in a particular column in a particular sheet each time.
Example: when it is 5am, the macro copies the value in cell k4 and pastes it in m1, then when it is 6am the macro copies the value in cell k4 and pastes it in m2, then when it is 7am the macro copies the value in cell k4 and pastes it in m3, and so on!

Please help

werafa
10-15-2018, 05:14 PM
Hi,

your request is very cryptic, but it sounds like you need to turn a time value into a range reference.

you can define a range reference ( a cell) as follows



sub 1()

dim lNum as long

thisworkbook.worksheets("Sheet 1").range ("A"&lnum).value = somenumber

end sub

getting lNum will require that you read the time and convert it into an integer value. to do this, you can use

lnum = hour(the time)

where 'the time' is the time you are referencing. this will give you an integer between 1 and 23.

This should get you going
Werafa