J
Julie
Sorry for the mess up.
Hi! Can someone please help me with my code? I have
tried every possible way (I know) to get this to work and
I am I completely frustrated. I am using the code for a
summary page. My page varies everytime I import
information so I want to use 'LastRow' in my code because
I want the code to go to the last row of a certain column
and use that value. I am going to try to explain as much
as I can. I have 3 columns on my summary page.
Column A is blank and to be used for calculations
(percentage)
Column B has descriptions in it (all text)
Column F has numeric valuesin it. It is used for cost
for the description in Column B.
A B F
xyz Company 12000.00
abc Company 24000.00
def Company 12000.00
48000.00 (total)
I want column A to be a percentage using take C1 divided
by C4, C2/C4 and so on. The only problem is that I may
have four rows in my summary this month, but next month I
may have 24 rows. I have listed my code below, but It
doesn't seem to work. Any suggestions? Sorry it is so
long! Thanks in advance for any help given. Happy
Halloween!
'
' Adjust/Formulas Macro
' Macro recorded 10/29/2003 by Julie
'
'
Dim LastRow As Long
Dim wks As Worksheet
Dim Row_Num As Integer
Dim Head_Num As Integer
Dim i
Range("F6").Select
Set wks = ActiveSheet
Row_Num = ActiveCell.Row
LastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row
Head_Num = 6
i = Row_Num
Range("F6").Select
Do Until i > Head_Num
With wks
.Range("A6").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A6").AutoFill _
Destination:=Range("A6:A" & LastRow),
Type:=xlFillCopy
.Range("A7").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A7").AutoFill _
Destination:=.Range("A7:A" & LastRow),
Type:=xlFillDefault
.Range("A8").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A8").AutoFill _
Destination:=.Range("A8:A" & LastRow),
Type:=xlFillDefault
.Range("A9").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A9").AutoFill _
Destination:=.Range("A9:A" & LastRow),
Type:=xlFillDefault
.Range("A10").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A10").AutoFill _
Destination:=.Range("A10:A" & LastRow),
Type:=xlFillDefault
.Range("A11").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A11").AutoFill _
Destination:=.Range("A11:A" & LastRow),
Type:=xlFillDefault
.Range("A12").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A12").AutoFill _
Destination:=.Range("A12:A" & LastRow),
Type:=xlFillDefault
.Range("A13").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A13").AutoFill _
Destination:=.Range("A13:A" & LastRow),
Type:=xlFillDefault
.Range("A14").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A14").AutoFill _
Destination:=.Range("A14:A" & LastRow),
Type:=xlFillDefault
.Range("A15").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A15").AutoFill _
Destination:=.Range("A15:A" & LastRow),
Type:=xlFillDefault
.Range("A16").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A16").AutoFill _
Destination:=.Range("A16:A" & LastRow),
Type:=xlFillDefault
.Range("A17").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A17").AutoFill _
Destination:=.Range("A17:A" & LastRow),
Type:=xlFillDefault
.Range("A18").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A18").AutoFill _
Destination:=.Range("A18:A" & LastRow),
Type:=xlFillDefault
.Range("A19").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A19").AutoFill _
Destination:=.Range("A19:A" & LastRow),
Type:=xlFillDefault
.Range("A20").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A20").AutoFill _
Destination:=.Range("A20:A" & LastRow),
Type:=xlFillDefault
End With
i = i - 1
Loop
I also tried to define last row this way:
LastRow = Range("F:F").SpecialCell(xlCellTypeLastCell).Row
Thanks,
Julie
Hi! Can someone please help me with my code? I have
tried every possible way (I know) to get this to work and
I am I completely frustrated. I am using the code for a
summary page. My page varies everytime I import
information so I want to use 'LastRow' in my code because
I want the code to go to the last row of a certain column
and use that value. I am going to try to explain as much
as I can. I have 3 columns on my summary page.
Column A is blank and to be used for calculations
(percentage)
Column B has descriptions in it (all text)
Column F has numeric valuesin it. It is used for cost
for the description in Column B.
A B F
xyz Company 12000.00
abc Company 24000.00
def Company 12000.00
48000.00 (total)
I want column A to be a percentage using take C1 divided
by C4, C2/C4 and so on. The only problem is that I may
have four rows in my summary this month, but next month I
may have 24 rows. I have listed my code below, but It
doesn't seem to work. Any suggestions? Sorry it is so
long! Thanks in advance for any help given. Happy
Halloween!
'
' Adjust/Formulas Macro
' Macro recorded 10/29/2003 by Julie
'
'
Dim LastRow As Long
Dim wks As Worksheet
Dim Row_Num As Integer
Dim Head_Num As Integer
Dim i
Range("F6").Select
Set wks = ActiveSheet
Row_Num = ActiveCell.Row
LastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row
Head_Num = 6
i = Row_Num
Range("F6").Select
Do Until i > Head_Num
With wks
.Range("A6").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A6").AutoFill _
Destination:=Range("A6:A" & LastRow),
Type:=xlFillCopy
.Range("A7").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A7").AutoFill _
Destination:=.Range("A7:A" & LastRow),
Type:=xlFillDefault
.Range("A8").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A8").AutoFill _
Destination:=.Range("A8:A" & LastRow),
Type:=xlFillDefault
.Range("A9").FormulaR1C1 = "=RC[5]/" & LastRow
.Range("A9").AutoFill _
Destination:=.Range("A9:A" & LastRow),
Type:=xlFillDefault
.Range("A10").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A10").AutoFill _
Destination:=.Range("A10:A" & LastRow),
Type:=xlFillDefault
.Range("A11").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A11").AutoFill _
Destination:=.Range("A11:A" & LastRow),
Type:=xlFillDefault
.Range("A12").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A12").AutoFill _
Destination:=.Range("A12:A" & LastRow),
Type:=xlFillDefault
.Range("A13").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A13").AutoFill _
Destination:=.Range("A13:A" & LastRow),
Type:=xlFillDefault
.Range("A14").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A14").AutoFill _
Destination:=.Range("A14:A" & LastRow),
Type:=xlFillDefault
.Range("A15").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A15").AutoFill _
Destination:=.Range("A15:A" & LastRow),
Type:=xlFillDefault
.Range("A16").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A16").AutoFill _
Destination:=.Range("A16:A" & LastRow),
Type:=xlFillDefault
.Range("A17").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A17").AutoFill _
Destination:=.Range("A17:A" & LastRow),
Type:=xlFillDefault
.Range("A18").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A18").AutoFill _
Destination:=.Range("A18:A" & LastRow),
Type:=xlFillDefault
.Range("A19").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A19").AutoFill _
Destination:=.Range("A19:A" & LastRow),
Type:=xlFillDefault
.Range("A20").FormulaR1C1 = "=RC[5]/" &
LastRow
.Range("A20").AutoFill _
Destination:=.Range("A20:A" & LastRow),
Type:=xlFillDefault
End With
i = i - 1
Loop
I also tried to define last row this way:
LastRow = Range("F:F").SpecialCell(xlCellTypeLastCell).Row
Thanks,
Julie