Hello,
The computer system my company uses exports to excel in an ugly and unusable way. Normally i manually sort the data but I recently took an excel course and learned a bit about macro's. I have a macro set up to auto format the data but i was wondering if it can be set up to run on a highlighted area? the data changes each time it is exported and there is other data in the same report that needs to be formatted differently to be usable.
here is what i have so far.
The computer system my company uses exports to excel in an ugly and unusable way. Normally i manually sort the data but I recently took an excel course and learned a bit about macro's. I have a macro set up to auto format the data but i was wondering if it can be set up to run on a highlighted area? the data changes each time it is exported and there is other data in the same report that needs to be formatted differently to be usable.
here is what i have so far.
Code:
Range("A2").Select
ActiveCell.FormulaR1C1 = "=RC[4]*100"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A42"), Type:=xlFillDefault
Range("A2:A42").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "100"
Selection.AutoFill Destination:=Range("E2:E42"), Type:=xlFillDefault
Range("E2:E42").Select
Selection.NumberFormat = "#,##0.000"
Selection.NumberFormat = "#,##0.00"
Selection.NumberFormat = "#,##0.0"
Selection.NumberFormat = "#,##0"
Range("D1:D42").Select
Selection.Cut
Range("C1").Select
ActiveSheet.Paste
Columns("C:C").EntireColumn.AutoFit
Columns("D:D").ColumnWidth = 41.14
End Sub
Sub formatbreakouts()
'
' formatbreakouts Macro
' Formatting ingredient breakouts
'
'
Columns("C:C").EntireColumn.AutoFit
Columns("D:D").EntireColumn.AutoFit
Range("E2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-3]*100"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E42"), Type:=xlFillDefault
Range("E2:E42").Select
ActiveWindow.SmallScroll Down:=-21
Range("F2").Select
ActiveCell.FormulaR1C1 = "=lower"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=LOWER(RC[-2]:R[18]C[-2])+"","""
Range("F2").Select
ActiveCell.FormulaR1C1 = "=LOWER(RC[-2])+"","""
Range("F2").Select
ActiveCell.FormulaR1C1 = "=LOWER(RC[-2])&"","""
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F42"), Type:=xlFillDefault
Range("F2:F42").Select
Selection.Cut
Application.CutCopyMode = False
Selection.Copy
Range("D2").Select
End Sub
Last edited by a moderator: