Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Newbie: VBA problem when copying cell range

When I try to copy a horizontal cell range to the rows below, the cell
references in my formulas is incremented by two instead of one, as explained
in the example below.

Given this formulas C1=A1+B1, and D1=A1-B1

Using the formula below, the C2 formula then becomes A2+B2 as expected, while
C3 formula becomes A4+B4 (D3=A4-B4) and not A3+B3,
C4 formula becomes A6+B6 (D4=A6-B6) and not A4+B4 and so on.

With Worksheets("Sheet1")
..Range(.Cells(2, 3), .Cells(8, 5)).FormulaR1C1 = .Range(.Cells(1, 3),
..Cells(1, 5)).FormulaR1C1
End With

Please explain me why this happen, and how the formula should be corrected!

Regards

Frank Krogh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Newbie: VBA problem when copying cell range

do it this way and you will get what you want:

Sub ABC()
With Worksheets("Sheet1")
..Range(.Cells(1, 3), .Cells(8, 5)) _
.Formula = .Range(.Cells(1, 3), _
..Cells(1, 5)).Formula
End With

End Sub

Note that I removed the R1C1 and I reassigned the formula to the original
cells (included them on the left side as well).

Use autofill if you don't want to have to think about it.

--
Regards,
Tom Ogilvy


"Frank" wrote:

When I try to copy a horizontal cell range to the rows below, the cell
references in my formulas is incremented by two instead of one, as explained
in the example below.

Given this formulas C1=A1+B1, and D1=A1-B1

Using the formula below, the C2 formula then becomes A2+B2 as expected, while
C3 formula becomes A4+B4 (D3=A4-B4) and not A3+B3,
C4 formula becomes A6+B6 (D4=A6-B6) and not A4+B4 and so on.

With Worksheets("Sheet1")
.Range(.Cells(2, 3), .Cells(8, 5)).FormulaR1C1 = .Range(.Cells(1, 3),
.Cells(1, 5)).FormulaR1C1
End With

Please explain me why this happen, and how the formula should be corrected!

Regards

Frank Krogh

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
copying cell formula newbie. Thank You No Name Excel Discussion (Misc queries) 0 June 10th 07 10:53 PM
copying cell formula newbie. No Name Excel Discussion (Misc queries) 1 June 10th 07 10:15 PM
Problem copying a range to another file Bob Lehrer Excel Programming 5 March 20th 06 12:07 PM
copying and pasting range problem Henrik Excel Programming 1 November 15th 05 01:49 PM
Problem copying a range to a different workbook [email protected] Excel Programming 3 December 8th 04 01:43 AM


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