Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
In D1 use a formula and copy that down =TEXT(C1,"hhmm") OR Sub Mac() lngLastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row For lngRow = 1 To lngLastRow Range("D" & lngRow) = Format(Range("c" & lngRow), "hhmm") Next End Sub If this post helps click Yes --------------- Jacob Skaria "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Sub ReplaceColon() Dim Rng As Range LastRow = Range("C" & Rows.Count).End(xlUp).Row Range("D2").Formula = "=text(C2,""HHMM"")" Range("D2").Copy _ Destination:=Range("D2:D" & LastRow) End Sub "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Hello Jacob from Steved
I'm getting a Compile error "Variable Not Defined" your script is highlighting "lngLastRow =" Is this because in the Formula Bar 13:05 is displayed as 1:05:00 p.m. I'm very sorry this is beyond my understanding as to what is happening and I thank you for taking timeout on my issue. "Jacob Skaria" wrote: In D1 use a formula and copy that down =TEXT(C1,"hhmm") OR Sub Mac() lngLastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row For lngRow = 1 To lngLastRow Range("D" & lngRow) = Format(Range("c" & lngRow), "hhmm") Next End Sub If this post helps click Yes --------------- Jacob Skaria "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou ----------------------------------------------------------------------------- Our Peering Groups change Visit : http://spacesst.com/peerin |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Hello Joel from Steved
Joel your script is showing a Compile error "Variable not defined" In your case it is highlighting "LastRow =" Is this because 13:05 in the worksheet, is displayed as 1:05:00 p.m. in the Formula Bar. I thankyou for taking timeout on my issue. "Joel" wrote: Sub ReplaceColon() Dim Rng As Range LastRow = Range("C" & Rows.Count).End(xlUp).Row Range("D2").Formula = "=text(C2,""HHMM"")" Range("D2").Copy _ Destination:=Range("D2:D" & LastRow) End Sub "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou ----------------------------------------------------------------------------- Our Peering Groups change Visit : http://spacesst.com/peerin |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
add the declaration
Dim LastRow as Long "Steved" wrote: Hello Joel from Steved Joel your script is showing a Compile error "Variable not defined" In your case it is highlighting "LastRow =" Is this because 13:05 in the worksheet, is displayed as 1:05:00 p.m. in the Formula Bar. I thankyou for taking timeout on my issue. "Joel" wrote: Sub ReplaceColon() Dim Rng As Range LastRow = Range("C" & Rows.Count).End(xlUp).Row Range("D2").Formula = "=text(C2,""HHMM"")" Range("D2").Copy _ Destination:=Range("D2:D" & LastRow) End Sub "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou ----------------------------------------------------------------------------- Less Spam Better enjoyable experience Visit : news://spacesst.com |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Hello Joel
Thankyou very much. With your script is it possible to do replace in the same column ie Column C:\ please. "Joel" wrote: add the declaration Dim LastRow as Long "Steved" wrote: Hello Joel from Steved Joel your script is showing a Compile error "Variable not defined" In your case it is highlighting "LastRow =" Is this because 13:05 in the worksheet, is displayed as 1:05:00 p.m. in the Formula Bar. I thankyou for taking timeout on my issue. "Joel" wrote: Sub ReplaceColon() Dim Rng As Range LastRow = Range("C" & Rows.Count).End(xlUp).Row Range("D2").Formula = "=text(C2,""HHMM"")" Range("D2").Copy _ Destination:=Range("D2:D" & LastRow) End Sub "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou ----------------------------------------------------------------------------- Less Spam Better enjoyable experience Visit : news://spacesst.com |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Yes and no. You can put the formula in an unused column like IV. Then paste
the values back into column C. see changes below Sub ReplaceColon() Dim Rng As Range Dim LastRow as long LastRow = Range("C" & Rows.Count).End(xlUp).Row 'put formula in column IV and copy down column Range("IV2").Formula = "=text(C2,""HHMM"")" Range("IV2").Copy _ Destination:=Range("IV2:IV" & LastRow) 'pastespecial values back into column C Range("IV2:IV" & LastRow).Copy Range("C2").pasteSpecial _ paste:=xlpastevalues 'delete column IV columns("IV").delete End Sub "Steved" wrote: Hello Joel Thankyou very much. With your script is it possible to do replace in the same column ie Column C:\ please. "Joel" wrote: add the declaration Dim LastRow as Long "Steved" wrote: Hello Joel from Steved Joel your script is showing a Compile error "Variable not defined" In your case it is highlighting "LastRow =" Is this because 13:05 in the worksheet, is displayed as 1:05:00 p.m. in the Formula Bar. I thankyou for taking timeout on my issue. "Joel" wrote: Sub ReplaceColon() Dim Rng As Range LastRow = Range("C" & Rows.Count).End(xlUp).Row Range("D2").Formula = "=text(C2,""HHMM"")" Range("D2").Copy _ Destination:=Range("D2:D" & LastRow) End Sub "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou ----------------------------------------------------------------------------- Less Spam Better enjoyable experience Visit : news://spacesst.com |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
Hello Joel
Excellent and I thankyou. Steved "Joel" wrote: Yes and no. You can put the formula in an unused column like IV. Then paste the values back into column C. see changes below Sub ReplaceColon() Dim Rng As Range Dim LastRow as long LastRow = Range("C" & Rows.Count).End(xlUp).Row 'put formula in column IV and copy down column Range("IV2").Formula = "=text(C2,""HHMM"")" Range("IV2").Copy _ Destination:=Range("IV2:IV" & LastRow) 'pastespecial values back into column C Range("IV2:IV" & LastRow).Copy Range("C2").pasteSpecial _ paste:=xlpastevalues 'delete column IV columns("IV").delete End Sub "Steved" wrote: Hello Joel Thankyou very much. With your script is it possible to do replace in the same column ie Column C:\ please. "Joel" wrote: add the declaration Dim LastRow as Long "Steved" wrote: Hello Joel from Steved Joel your script is showing a Compile error "Variable not defined" In your case it is highlighting "LastRow =" Is this because 13:05 in the worksheet, is displayed as 1:05:00 p.m. in the Formula Bar. I thankyou for taking timeout on my issue. "Joel" wrote: Sub ReplaceColon() Dim Rng As Range LastRow = Range("C" & Rows.Count).End(xlUp).Row Range("D2").Formula = "=text(C2,""HHMM"")" Range("D2").Copy _ Destination:=Range("D2:D" & LastRow) End Sub "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou ----------------------------------------------------------------------------- Less Spam Better enjoyable experience Visit : news://spacesst.com |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
My attempt to do a Replace
add the two lines as shown :- Sub Mac() DIM lngLastRow As Long ' ADD THIS DIM lngRow As Long ' ADD THIS lngLastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row For lngRow = 1 To lngLastRow Range("D" & lngRow) = Format(Range("c" & lngRow), "hhmm") Next End Sub "Steved" wrote in message ... Hello Jacob from Steved I'm getting a Compile error "Variable Not Defined" your script is highlighting "lngLastRow =" Is this because in the Formula Bar 13:05 is displayed as 1:05:00 p.m. I'm very sorry this is beyond my understanding as to what is happening and I thank you for taking timeout on my issue. "Jacob Skaria" wrote: In D1 use a formula and copy that down =TEXT(C1,"hhmm") OR Sub Mac() lngLastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row For lngRow = 1 To lngLastRow Range("D" & lngRow) = Format(Range("c" & lngRow), "hhmm") Next End Sub If this post helps click Yes --------------- Jacob Skaria "Steved" wrote: Hello from Steved Whats my Objective simply replace Semi colon (":") example 07:40 to 0740 or 13:05 to 1305 The information is in Column C:C and I've asking it to be put in Column D:D please Sub ReplaceColon() For X = 1 To 1 Dim Rng As Range Set Rng = Format(Range("C2"), "hhmm").End(xlUp) Range("C2").Select For Each cell In Rng If cell.Value < "" Then ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=MID(RC[-1],1+(LEFT(RC[-1])=""0""),99)" ActiveCell.Offset(1, -1).Select End If Next cell Next X End Sub Thankyou |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need Help in VLOOKUP (second attempt) | Excel Programming | |||
Sumproduct - Second Attempt | Excel Worksheet Functions | |||
Do until code attempt.. | Excel Programming | |||
my first attempt at R1C1 in vba | Excel Programming | |||
1st attempt vba-how do i whatnext in this sub | Excel Programming |