ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Modified:- Macro to Generate a new Column!!! (https://www.excelbanter.com/excel-worksheet-functions/149923-modified-macro-generate-new-column.html)

Inder

Modified:- Macro to Generate a new Column!!!
 
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


Toppers

Modified:- Macro to Generate a new Column!!!
 
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

"Inder" wrote:

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




All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com