Beginner to VBA

gdmeckes

New Member
Joined
Nov 18, 2015
Messages
10
Hello,

I've been creating Macros for Excel for the past couple of months, and I have an error in one of them that I need to fix, which has brought me to the VBA code world. Where is the best place/site to try to begin learning to write and edit macros in VBA?
 
OK, the LR line needs to move up to the top...
Code:
Sub PayloadDetailInsertColumnstoRound()
Dim lr As Long
lr = Cells(Rows.Count, "F").End(xlUp).Row
Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.NumberFormat = "General"
Range("B1").Value = "Loads"
Range("B2:B" & lr).Value = "1"
Columns("E:E").NumberFormat = "0"
Columns("G:G").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("J:J").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("L:L").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("N:N").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("P:P").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("S:S").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("F1").Copy Range("G1")
Range("I1").Copy Range("J1")
Range("K1").Copy Range("L1")
Range("M1").Copy Range("N1")
Range("O1").Copy Range("P1")
Range("R1").Copy Range("S1")
Range("G1").Value = "Travel Empty Time Round"
Range("J1").Value = "Stopped Empty Time Round"
Range("L1").Value = "Load Time Round"
Range("N1").Value = "Stopped Loaded Time Round"
Range("P1").Value = "Loaded Travel Time Round"
Range("S1").Value = "Cycle Time Round"
Range("G2:G" & lr).Formula = "=ROUND(F2*(86400/30),0)/(86400/30)"
Range("G2:G" & lr).NumberFormat = "mm:ss"
Range("G2").Copy Range("J2:J" & lr)
Range("J2").Copy Range("L2:L" & lr)
Range("L2").Copy Range("N2:N" & lr)
Range("N2").Copy Range("P2:P" & lr)
Range("P2").Copy Range("S2:S" & lr)
Range("S2:S" & lr).NumberFormat = "h:mm:ss"
End Sub
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,216,102
Messages
6,128,852
Members
449,471
Latest member
lachbee

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