#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Copy Insert Macro

HI!

Heres the issue:

I have a range of data in columns A-H. I have a macro that filters those
columns. So sometimes the Row is 5 sometimes 20 and sometimes 43, all random.
What I need the macro to do is the highest column to the last row that has
data in it, the data needs to be copied. Then I need it to insert into
another spreadsheet, same amount of columns but B-I.

This is what I have:

Range("A195:H195").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IL").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

It only iserts 1 cell and moves all contents below b2 down 1 row, it also
only grabs row 195, not the highest row...
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Copy Insert Macro

LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

HI!

Heres the issue:

I have a range of data in columns A-H. I have a macro that filters those
columns. So sometimes the Row is 5 sometimes 20 and sometimes 43, all random.
What I need the macro to do is the highest column to the last row that has
data in it, the data needs to be copied. Then I need it to insert into
another spreadsheet, same amount of columns but B-I.

This is what I have:

Range("A195:H195").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IL").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

It only iserts 1 cell and moves all contents below b2 down 1 row, it also
only grabs row 195, not the highest row...

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Copy Insert Macro

Joel,

Thats not exactly it... I think I can simplify this. I want it to copy data
in column A100:H150 and paste it right below the data that I have in the
other spreadsheet.

"Joel" wrote:

LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

HI!

Heres the issue:

I have a range of data in columns A-H. I have a macro that filters those
columns. So sometimes the Row is 5 sometimes 20 and sometimes 43, all random.
What I need the macro to do is the highest column to the last row that has
data in it, the data needs to be copied. Then I need it to insert into
another spreadsheet, same amount of columns but B-I.

This is what I have:

Range("A195:H195").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IL").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

It only iserts 1 cell and moves all contents below b2 down 1 row, it also
only grabs row 195, not the highest row...

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Copy Insert Macro

Either
set CopyRange = Range(A100:H150)
with Sheets("IL")
LastRow = .Range("A195").End(xlDown).Row
CopyRange.Copy destination:=.Range("A" & LastRow)
end with

or
set CopyRange = Range(A100:H150)
with Sheets("IL")
LastRow = .Range("A195").End(xlDown).Row
.Range("A" & LastRow).Insert Shift:=xlDown
end with


LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

Joel,

Thats not exactly it... I think I can simplify this. I want it to copy data
in column A100:H150 and paste it right below the data that I have in the
other spreadsheet.

"Joel" wrote:

LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

HI!

Heres the issue:

I have a range of data in columns A-H. I have a macro that filters those
columns. So sometimes the Row is 5 sometimes 20 and sometimes 43, all random.
What I need the macro to do is the highest column to the last row that has
data in it, the data needs to be copied. Then I need it to insert into
another spreadsheet, same amount of columns but B-I.

This is what I have:

Range("A195:H195").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IL").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

It only iserts 1 cell and moves all contents below b2 down 1 row, it also
only grabs row 195, not the highest row...

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Copy Insert Macro

Joel,

The part that I think your missing is that the data is filtered, this is
what the whole script looks like:

Sheets("SFP").Select
Selection.AutoFilter Field:=12, Criteria1:="IN"
Range("A2:H2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IN").Select
Range("B2").Select
Selection.Insert Shift:=xlDown

What that does is it inserts a cell in b2 and shifts everything else
down...I also necessarily don't want it to start at A2:H2, I would like it to
start at the first row ,after the filter is changed, that has data in it,
except for the header.

I would just like to thank you for helping me
also!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

"Joel" wrote:

Either
set CopyRange = Range(A100:H150)
with Sheets("IL")
LastRow = .Range("A195").End(xlDown).Row
CopyRange.Copy destination:=.Range("A" & LastRow)
end with

or
set CopyRange = Range(A100:H150)
with Sheets("IL")
LastRow = .Range("A195").End(xlDown).Row
.Range("A" & LastRow).Insert Shift:=xlDown
end with


LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

Joel,

Thats not exactly it... I think I can simplify this. I want it to copy data
in column A100:H150 and paste it right below the data that I have in the
other spreadsheet.

"Joel" wrote:

LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

HI!

Heres the issue:

I have a range of data in columns A-H. I have a macro that filters those
columns. So sometimes the Row is 5 sometimes 20 and sometimes 43, all random.
What I need the macro to do is the highest column to the last row that has
data in it, the data needs to be copied. Then I need it to insert into
another spreadsheet, same amount of columns but B-I.

This is what I have:

Range("A195:H195").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IL").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

It only iserts 1 cell and moves all contents below b2 down 1 row, it also
only grabs row 195, not the highest row...



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Copy Insert Macro

Is this better?


Sub test10()

Sheets("SFP").Select
Selection.AutoFilter Field:=12, Criteria1:="IN"
addr = ActiveSheet.AutoFilter.Range.Address
Set addrRange = Range(addr)
Set newRange = addrRange.Resize(addrRange.Rows.Count - 1)
Set newRange = newRange.Offset(1, 0)
newRange.Copy

Sheets("IN").Select
Range("B2").Select
Selection.Insert Shift:=xlDown

End Sub


"Schwimms" wrote:

Joel,

The part that I think your missing is that the data is filtered, this is
what the whole script looks like:

Sheets("SFP").Select
Selection.AutoFilter Field:=12, Criteria1:="IN"
Range("A2:H2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IN").Select
Range("B2").Select
Selection.Insert Shift:=xlDown

What that does is it inserts a cell in b2 and shifts everything else
down...I also necessarily don't want it to start at A2:H2, I would like it to
start at the first row ,after the filter is changed, that has data in it,
except for the header.

I would just like to thank you for helping me
also!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

"Joel" wrote:

Either
set CopyRange = Range(A100:H150)
with Sheets("IL")
LastRow = .Range("A195").End(xlDown).Row
CopyRange.Copy destination:=.Range("A" & LastRow)
end with

or
set CopyRange = Range(A100:H150)
with Sheets("IL")
LastRow = .Range("A195").End(xlDown).Row
.Range("A" & LastRow).Insert Shift:=xlDown
end with


LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

Joel,

Thats not exactly it... I think I can simplify this. I want it to copy data
in column A100:H150 and paste it right below the data that I have in the
other spreadsheet.

"Joel" wrote:

LastRow = Range("A195").End(xlDown).Row
rows("195:" & LastRow).copy
Sheets("IL").Range("B2").Insert Shift:=xlDown



"Schwimms" wrote:

HI!

Heres the issue:

I have a range of data in columns A-H. I have a macro that filters those
columns. So sometimes the Row is 5 sometimes 20 and sometimes 43, all random.
What I need the macro to do is the highest column to the last row that has
data in it, the data needs to be copied. Then I need it to insert into
another spreadsheet, same amount of columns but B-I.

This is what I have:

Range("A195:H195").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("IL").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

It only iserts 1 cell and moves all contents below b2 down 1 row, it also
only grabs row 195, not the highest row...

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 insert a row and copy down formulas from row above Sal Excel Discussion (Misc queries) 2 December 3rd 07 05:33 AM
Macro - Insert/Copy John Britto Excel Discussion (Misc queries) 0 November 15th 07 10:01 AM
Macro to Insert and copy entire row CCrew2000 Excel Discussion (Misc queries) 3 June 26th 07 03:16 PM
Macro that will Cut rows and then insert-copy or append rod Excel Discussion (Misc queries) 3 October 21st 06 04:50 PM
Copy and insert cell info macro help JackR Excel Discussion (Misc queries) 2 March 21st 06 03:22 PM


All times are GMT +1. The time now is 10:08 PM.

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"