LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default More to Error in code

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code error M&M[_2_] Excel Discussion (Misc queries) 4 July 13th 07 12:20 AM
Code error N.F[_2_] Excel Discussion (Misc queries) 1 July 2nd 07 11:13 PM
Code Error Tom Excel Discussion (Misc queries) 0 February 21st 06 03:01 PM
Code error ?? Anthony Excel Discussion (Misc queries) 2 February 9th 05 10:31 PM
Error code=2 Derek[_5_] Excel Programming 1 October 14th 03 12:41 PM


All times are GMT +1. The time now is 04:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"