Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default COPY BY MACRO DOWN TO LAST VALUE CELL IN COLUMN "A"

Hi all, I have macro set on a button (see below) in my Sheet2

Sub FORMULAS()
Dim ic As Long
With Sheets("SPLIT")
.Range("G2").FormulaR1C1 = "=RC[-6]&RC[-5]&RC[-4]"
.Range("H2").FormulaR1C1 = "=IF(RC[-1]=R[1]C[-1],"""",RC[-1])"
.Range("I2").FormulaR1C1 =
"=IF(RC[-1]="""","""",SUMIF(R2C7:R50000C7,RC[-1],R2C5:R50000C5))"
.Range("J2").FormulaR1C1 = "=ROUND(RC[-5],0)"
.Range("K2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("L2").FormulaR1C1 =
"=IF(RC[-4]="""","""",SUMIF(R2C7:R50000C7,RC[-4],R2C11:R50000C11))"
.Range("M2").FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-4]-RC[-1])"
.Range("N2").FormulaR1C1 =
"=IF(RC[-1]="""","""",SUM(RC[-3],RC[-1]))"
.Range("O2").FormulaR1C1 = "=IF(RC[-1]="""",RC[-4],RC[-1])"
.Range("P2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("Q2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("R2").FormulaR1C1 =
"=IF(RC[-10]="""","""",SUMIF(R2C7:R50000C7,RC[-10],R2C17:R50000C17))"
ic = Cells(Rows.Count, "A").End(xlUp).Row
.Range("G2:R2").Copy .Range("G2").Offset(0, 0).Range("A1:A" & ic -
1)
Application.CutCopyMode = False
End With

End Sub

I get error when i run the macro and this line (see below) get
highligted in module
..Range("G2:R2").Copy .Range("G2").Offset(0, 0).Range("A1:A" & ic - 1)
basically i am try to put formulas by macro in cells from G2 to R2 of
Sheet("SPLIT") and then i want macro to copy those formulas from
range G3 to R3 down to last value cell in column A. Please can
anybody tell that how can i correct my macro above or what am i doing
wrong? Thanks in advance for help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default COPY BY MACRO DOWN TO LAST VALUE CELL IN COLUMN "A"

Hi

Look at this

Sub FORMULAS()
Dim ic As Long
Dim LastRow As Integer
LastRow = Range("A65536").End(xlUp).Row

With Sheets("SPLIT")
.Range("G2").FormulaR1C1 = "=RC[-6]&RC[-5]&RC[-4]"
.Range("H2").FormulaR1C1 = "=IF(RC[-1]=R[1]C[-1],"""",RC[-1])"
.Range("I2").FormulaR1C1 =
"=IF(RC[-1]="""","""",SUMIF(R2C7:R50000C7,RC[-1],R2C5:R50000C5))"
.Range("J2").FormulaR1C1 = "=ROUND(RC[-5],0)"
.Range("K2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("L2").FormulaR1C1 =
"=IF(RC[-4]="""","""",SUMIF(R2C7:R50000C7,RC[-4],R2C11:R50000C11))"
.Range("M2").FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-4]-RC[-1])"
.Range("N2").FormulaR1C1 = "=IF(RC[-1]="""","""",SUM(RC[-3],RC[-1]))"
.Range("O2").FormulaR1C1 = "=IF(RC[-1]="""",RC[-4],RC[-1])"
.Range("P2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("Q2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("R2").FormulaR1C1 =
"=IF(RC[-10]="""","""",SUMIF(R2C7:R50000C7,RC[-10],R2C17:R50000C17))"
ic = Cells(Rows.Count, "A").End(xlUp).Row
.Range("G2:R2").Copy .Range("G3", .Cells(LastRow, "R"))
Application.CutCopyMode = False
End With

End Sub

Regards,
Per

"K" skrev i meddelelsen
...
Hi all, I have macro set on a button (see below) in my Sheet2

Sub FORMULAS()
Dim ic As Long
With Sheets("SPLIT")
.Range("G2").FormulaR1C1 = "=RC[-6]&RC[-5]&RC[-4]"
.Range("H2").FormulaR1C1 = "=IF(RC[-1]=R[1]C[-1],"""",RC[-1])"
.Range("I2").FormulaR1C1 =
"=IF(RC[-1]="""","""",SUMIF(R2C7:R50000C7,RC[-1],R2C5:R50000C5))"
.Range("J2").FormulaR1C1 = "=ROUND(RC[-5],0)"
.Range("K2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("L2").FormulaR1C1 =
"=IF(RC[-4]="""","""",SUMIF(R2C7:R50000C7,RC[-4],R2C11:R50000C11))"
.Range("M2").FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-4]-RC[-1])"
.Range("N2").FormulaR1C1 =
"=IF(RC[-1]="""","""",SUM(RC[-3],RC[-1]))"
.Range("O2").FormulaR1C1 = "=IF(RC[-1]="""",RC[-4],RC[-1])"
.Range("P2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("Q2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Range("R2").FormulaR1C1 =
"=IF(RC[-10]="""","""",SUMIF(R2C7:R50000C7,RC[-10],R2C17:R50000C17))"
ic = Cells(Rows.Count, "A").End(xlUp).Row
.Range("G2:R2").Copy .Range("G2").Offset(0, 0).Range("A1:A" & ic -
1)
Application.CutCopyMode = False
End With

End Sub

I get error when i run the macro and this line (see below) get
highligted in module
.Range("G2:R2").Copy .Range("G2").Offset(0, 0).Range("A1:A" & ic - 1)
basically i am try to put formulas by macro in cells from G2 to R2 of
Sheet("SPLIT") and then i want macro to copy those formulas from
range G3 to R3 down to last value cell in column A. Please can
anybody tell that how can i correct my macro above or what am i doing
wrong? Thanks in advance for help


Reply
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
Macro to copy a Cell Content automatically IF G12 cell <"" Ms-Exl-Learner Excel Discussion (Misc queries) 6 December 15th 09 07:52 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
find "Cancellation" in column "A" and copy all data from Columns B-F onto another Sheet bjohnson Excel Programming 1 September 20th 07 04:02 PM
Need the formula or macro. If i enter today date in the cell (Row 1,Column 2) and on tab out, the column 1 cell should be filled with "corresponding Day" of the date kakasay Excel Discussion (Misc queries) 1 January 22nd 07 12:31 PM
Need Formula or macro. If i enter today date in the cell (Row 1,Column 2) and on tab out, the column 1 cell should be filled with "corresponding Day" of the date kakasay Excel Discussion (Misc queries) 1 January 22nd 07 12:31 PM


All times are GMT +1. The time now is 09:25 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"