Modified:-> Macro to Generate a new Column!!!

I

Inder

i have tried to put a chunk of code ... but i m unable
to make it fit as per my problem. can u help me out!
My scenario is as follows:

PunchDate DateIn Timein DateOut Timeout Shift Dept Reg LCh OT
DT BR Total HWH Abst Remarks


The above r the columns of the Excel report generated,
i have shown them in 2 rows, otherwise all these
columns r in one row only and r generated from A-Q in
Excel sheet. i want the condition to be enforced on
TimeIn column and display the result of the condition
in a new column which shud be generated after the last
columns i.e. 'Remarks' . And Also it shud affect all the roecords till
the end of the sheet!
i tried to put on a code... but i cudn't make it! i m
doin like this... i know i m doin something stupid.

Dim MyCell As Object
For Each MyCell In Range(Cells(3, 7), Cells(3,
7).End(xlDown)).Cells
If MyCell.Value > TimeSerial(10, 0, 0) Then
MyCell.Offset(0, 1).Value = TimeSerial(11, 0, 0)
Else
MyCell.Offset(0, 1).Value = ""
End If
Next


please help me out!
thanx n regards
Inder
 
T

Toppers

Slightly confused about columns but try this ...

Dim lastrow As Long
Dim irow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For irow = 2 To lastrow
If Cells(irow, "C") > TimeSerial(10, 0, 0) Then
Cells(irow, "R") = TimeSerial(11, 0, 0)
Else
Cells(irow, "R").Value = ""
End If
Next irow
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top