cimajc17

New Member
Joined
Jun 10, 2015
Messages
15
Hey, so I'm trying to use the AutoFill with Cells command an I am having trouble. Here is my code

Range("L2").Select
ActiveCell.FormulaR1C1 = "=(DATEVALUE(RC[-1]))"
Selection.NumberFormat = "m/d/yyyy"
Selection.AutoFill Destination:=Range(Cells(2, 12), Cells(lastRow2, 12)), Type:=xlFillDefault
'time conversion
Columns("N:N").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("N2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],LEN(RC[-1])-2)&"" ""&RIGHT(RC[-1],2)"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N452"), Type:=xlFillDefault

here is what I want
"date conversion
Range("L2").Select
ActiveCell.FormulaR1C1 = "=(DATEVALUE(RC[-1]))"
Selection.NumberFormat = "m/d/yyyy"
Selection.AutoFill Destination:=Range(Cells(2, 12), Cells(lastRow2, 12)), Type:=xlFillDefault

'time conversion

Columns("N:N").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("N2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],LEN(RC[-1])-2)&"" ""&RIGHT(RC[-1],2)"
Range("N2").Select
Selection.AutoFill Destination:=Range(Cells(2, 13), Cells(lastRow2, 13)), Type:=xlFillDefault

I'm confused because it works during the Date conversion but not the time conversion. also last row is a variable found by the following function.
Dim lastRow2 As Long
Dim row As Long
Dim startRow As Long
Dim col As Long
startRow = 1
col = 1
lastRow2 = Findlastrow(col)



Function Findlastrow(col) As Long
Findlastrow = Cells(Rows.Count, col).End(xlUp).row
End Function
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,326
Messages
6,124,260
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top