View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Arvi Laanemets Arvi Laanemets is offline
external usenet poster
 
Posts: 510
Default Excel2000: Insert a copy of row range

Hi


I almost have it!
......
For i = 1 To (varNeededEntries - varCurrentEntries)
Sheets("Sheet1").Range(RowX & ":" & (RowX+4)).Insert
(Sheets("Leht1").Range(RowX & ":" & (RowX+4)).Copy)
Next i
......

, but this copies all except cell merging. How to make this to copy cell
merging too? Manually it is copied! Below is manul operation saved as a
macro

Sub Macro3()
Rows("111:115").Select
Range("D111").Activate
' cells in ranges A111:A114, B111:B114 and C111:C114 are merged
Selection.Copy
Selection.Insert Shift:=xlDown
End Sub


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )




"Tom Ogilvy" wrote in message
...
Nothing in your loop changes. You perform the same action 1 to N times.
Makes no sense.

You need to increment your RowX within the loop. Also, you copy from
one
location to the same location. That makes no sense either. You shouldn't
have the destination range in parentheses.

Other than that, your description offers little insight into what your
problem is.



--
Regards,
Tom Ogilvy

"Arvi Laanemets" wrote in message
...
Hi

I need in VBA to add a 5-row range into a table (5 rows is a entry in
table).
The operation will be same as manually to copy a row range, and then

insert
copied cells to same location. All formats (cell merging included),
formulas, row heights, etc. must be copied too.

The code below copies the same range (initially, it has to be a pre-last
entry in table - using the last one makes a mess from all formulas) over,
instead inserting a new one. How to modify it?

....
For i = 1 To (varNeededEntries - varCurrentEntries)
Sheets("Sheet1").Range(RowX & ":" & (RowX+4)).Copy
(Sheets("Sheet1").Range(RowX & ":" & (RowX+4)))
Next i
....


Thanks in advance!

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )