Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing ****fs macro.
I am using Excel to keep track of shifts. I have three ****s and each are at
different times. I need a macro that will look through one column of start times and determines which shift (A, B, C) to put in another column. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing ****fs macro.
Sub fillInShiftColumn()
Dim cell as Range for each cell in Range(cells(2,Activecell.Column),cells(20,ActiveCe ll.Column)) if cell.Value = "A" then cell.offset(0,1).value = "B" elseif cell.Value = "B" then cell.offset(0,1).Value = "C" elseif cell.Value = "C" then cell.offset(0,1).ClearContents elsif cell.Value = "" then cell.offset(0,1).Value = "A" end if Next End sub or you said times Sub fillInShiftColumna() Dim timeA1 as Date, timeA2 as Date, timeB1 as Date Dim timeB2 as Date, timeC1 as Date, timeC2 as Date TimeB1 = TimeValue("8:00:00 AM") TimeB2 = TimeValue("3:59:59 PM") TimeA1 = TimeValue("4:00:00 PM") TimeA2 = TimeValue("11:59:59 PM") TimeC1 = TimeValue("00:00:00 AM") TimeC2 = TimeValue("7:59:59 AM") Dim cell as Range for each cell in Range(cells(2,Activecell.Column),cells(20,ActiveCe ll.Column)) if cell.Value = TimeB1 and cell.Value <= TimeB2 then cell.offset(0,1).value = "B" elseif cell.Value = TimeC1 and cell.Value <= TimeC2 then cell.offset(0,1).Value = "C" elseif cell.Value = TimeA1 and cell.Value M= TimeA2 then cell.offset(0,1).Value = "A" end if Next End sub This may help you realize you need to enrich your description. -- Regards, Tom Ogilvy "Co-Op dude" <Co-Op wrote in message ... I am using Excel to keep track of shifts. I have three ****s and each are at different times. I need a macro that will look through one column of start times and determines which shift (A, B, C) to put in another column. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing ****fs macro.
I apoligize for not being more thurough.
What I have is three shifts: A = 23:00 - 6 :59; B = 7:00 - 14:59; and C = 15:00 - 22:59. In one column will be the times and another will be for the shift letter. What I wanted to do was go through the column with the times listed and determine which shift it belonged to and then print the shift letter in the other blank column. If you need anymore information please ask. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing ****fs macro.
Sub fillInShiftColumn()
Dim cell as Range, tm as Date Dim v as Variant, v1 as Variant for each cell in Range(cells(2, _ Activecell.Column),cells(20,ActiveCell.Column)) v = ("6:59","14:59","22:59", "11:49") v1 = ("A","B","C","A") for i = lbound(v) to ubound(v) tm = TimeValue(v(i)) if cell.Value <= v(i) then cell.offset(0,1) = v1(i) end if Next Next End sub -- Regards, Tom Ogilvy "Delphi Student" <Delphi wrote in message ... I apoligize for not being more thurough. What I have is three shifts: A = 23:00 - 6 :59; B = 7:00 - 14:59; and C = 15:00 - 22:59. In one column will be the times and another will be for the shift letter. What I wanted to do was go through the column with the times listed and determine which shift it belonged to and then print the shift letter in the other blank column. If you need anymore information please ask. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro for comparing Hotel Prices | Excel Programming | |||
comparing text with macro | Excel Programming | |||
Macro (?) for comparing 2 Excel files/sheets | Excel Programming | |||
Macro for comparing two spreadsheets | Excel Programming | |||
Macro for comparing 2 values (number and date) | Excel Programming |