Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Insert cells

I hope I can explain this.

My macro takes a record list that starts on A9 of one sheet and pastes it to
another sheet. The record list goes from column A-H w/varying number of
rows. I need the macro to copy the blank cells in columns I-N because I am
pasting this above a separate record list that goes from column A-N. I
thought by doing "Range(Selection, Selection.End(xlToRight)).Select" twice it
would always copy & insert the blank cells, but it doesn't work.

When I run the macro it ignores the blank column I-N cells & the secondary
record list becomes separated. Columns A-H are moved below the inserted
cells, but columns I-N stay in their original place. What am I doing wrong?


Range("A9").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Sheet1").Select
Range("A8").Select
Selection.Insert Shift:=xlDown
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Insert cells

hi,
i wouldn't use .xl(direction) for blank rows in this case.
try something like this instead.

Dim r As Range
Dim c As Long
Set r = Range("A9")
Range(r, r.End(xlDown)).Select ' for varing number of rows
c = Selection.Rows.Count
r.Resize(c, 14).Select 'from A to N = 14 columns
Selection.Copy
more code

accually you don't need to select.....

Dim r As Range
Dim c As Long
Set r = Range("A9")
c = Range(r, r.End(xlDown)).rows.count
r.Resize(c, 14).copy
more code

regards
FSt1


"Munchkin" wrote:

I hope I can explain this.

My macro takes a record list that starts on A9 of one sheet and pastes it to
another sheet. The record list goes from column A-H w/varying number of
rows. I need the macro to copy the blank cells in columns I-N because I am
pasting this above a separate record list that goes from column A-N. I
thought by doing "Range(Selection, Selection.End(xlToRight)).Select" twice it
would always copy & insert the blank cells, but it doesn't work.

When I run the macro it ignores the blank column I-N cells & the secondary
record list becomes separated. Columns A-H are moved below the inserted
cells, but columns I-N stay in their original place. What am I doing wrong?


Range("A9").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Sheet1").Select
Range("A8").Select
Selection.Insert Shift:=xlDown

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
Insert same value across many cells Pete[_5_] New Users to Excel 1 September 16th 11 04:36 PM
Blocked from Inserting individual cells or Insert Cut Cells Ching-AHS Excel Discussion (Misc queries) 0 December 1st 09 05:47 PM
Insert Cells every other row Texas Nuckols Excel Discussion (Misc queries) 1 November 11th 09 10:38 PM
Insert Cut Cells susu Excel Discussion (Misc queries) 0 June 5th 08 05:02 PM
Can't insert cells kramer31 Excel Discussion (Misc queries) 2 March 6th 07 10:59 PM


All times are GMT +1. The time now is 02:53 AM.

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

About Us

"It's about Microsoft Excel"