Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Always creates the new range which is not needed in the macro

Hello,

I need your help, I am not too good in IT, all I can say that I can make
macro just by the help of this newsgroup.

I do not know what is wrong with this macro. When I print a range, it
becomes a new range included in this macro (x).

Now I have the range which I do not know whre it comes from which added to
my macro. Anyone can help me to find where it comes from?

This is my macro, if somebody can help me to only do my following named
rangesL
dbasseA002
dbasseA003
dbasseA004

How can I put it to this macro:

Thanks very much

Frank

Sub AutoShape7_Click()
' Macro recorded 5/10/2007 by Frank
' This is to copy all the data from interface worksheets to this summaryWBLA
' Button no.4
ActiveWindow.SmallScroll ToRight:=-5
Range("A9:Y1714").Select
Selection.ClearContents
Dim x As Object
For Each x In ActiveWorkbook.Names
Range(x).Copy
Sheets("SUMMARYWBLA").Select
Range("a65000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
Next x
Range("I2").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Always creates the new range which is not needed in the macro

It looks like you have a query or pivot table that added names into you
workbook which is normal. It think you need to skip over these unwanted
named ranges.

Sub AutoShape7_Click()
' Macro recorded 5/10/2007 by Frank
' This is to copy all the data from interface worksheets to this summaryWBLA
' Button no.4

'clear all data after row 9 in the worksheet
'Range("A9:Y1714").Select
'Selection.ClearContents
Rows("9:" & Rows.count).ClearContents
Dim x As Object
For Each x In ActiveWorkbook.Names
'skip named ranges starting with dbasse
if left(x.name,6) < "dbasse" then
'Range(x).Copy
With Sheets("SUMMARYWBLA")
LastRow = .Range("A" & Rows.Count).End(xlup).row
NewRow = LastRow + 1
Range(x.name).Copy _
Destination:=.Range("A" & NewRow)
End with
End if
Next x
End Sub

"Frank Situmorang" wrote:

Hello,

I need your help, I am not too good in IT, all I can say that I can make
macro just by the help of this newsgroup.

I do not know what is wrong with this macro. When I print a range, it
becomes a new range included in this macro (x).

Now I have the range which I do not know whre it comes from which added to
my macro. Anyone can help me to find where it comes from?

This is my macro, if somebody can help me to only do my following named
rangesL
dbasseA002
dbasseA003
dbasseA004

How can I put it to this macro:

Thanks very much

Frank

Sub AutoShape7_Click()
' Macro recorded 5/10/2007 by Frank
' This is to copy all the data from interface worksheets to this summaryWBLA
' Button no.4
ActiveWindow.SmallScroll ToRight:=-5
Range("A9:Y1714").Select
Selection.ClearContents
Dim x As Object
For Each x In ActiveWorkbook.Names
Range(x).Copy
Sheets("SUMMARYWBLA").Select
Range("a65000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
Next x
Range("I2").Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Always creates the new range which is not needed in the macro

Thanks very much Joel, your are awesome. It works perfectly after a bit
modifying your suggestion to be : if left(x.name,6) = "dbasse", which I think
you know that.

Again, thank you very very much.

Frank

"Joel" wrote:

It looks like you have a query or pivot table that added names into you
workbook which is normal. It think you need to skip over these unwanted
named ranges.

Sub AutoShape7_Click()
' Macro recorded 5/10/2007 by Frank
' This is to copy all the data from interface worksheets to this summaryWBLA
' Button no.4

'clear all data after row 9 in the worksheet
'Range("A9:Y1714").Select
'Selection.ClearContents
Rows("9:" & Rows.count).ClearContents
Dim x As Object
For Each x In ActiveWorkbook.Names
'skip named ranges starting with dbasse
if left(x.name,6) < "dbasse" then
'Range(x).Copy
With Sheets("SUMMARYWBLA")
LastRow = .Range("A" & Rows.Count).End(xlup).row
NewRow = LastRow + 1
Range(x.name).Copy _
Destination:=.Range("A" & NewRow)
End with
End if
Next x
End Sub

"Frank Situmorang" wrote:

Hello,

I need your help, I am not too good in IT, all I can say that I can make
macro just by the help of this newsgroup.

I do not know what is wrong with this macro. When I print a range, it
becomes a new range included in this macro (x).

Now I have the range which I do not know whre it comes from which added to
my macro. Anyone can help me to find where it comes from?

This is my macro, if somebody can help me to only do my following named
rangesL
dbasseA002
dbasseA003
dbasseA004

How can I put it to this macro:

Thanks very much

Frank

Sub AutoShape7_Click()
' Macro recorded 5/10/2007 by Frank
' This is to copy all the data from interface worksheets to this summaryWBLA
' Button no.4
ActiveWindow.SmallScroll ToRight:=-5
Range("A9:Y1714").Select
Selection.ClearContents
Dim x As Object
For Each x In ActiveWorkbook.Names
Range(x).Copy
Sheets("SUMMARYWBLA").Select
Range("a65000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
Next x
Range("I2").Select
End Sub

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
Can't highlight a single cell. Creates a range when I move curso Butch Walker Excel Worksheet Functions 4 July 6th 06 07:48 PM
Macro that creates a directory but... Andy Excel Programming 7 November 28th 04 06:23 AM
Macro in VBA: Setting a variable print range HELP NEEDED!! Ron de Bruin Excel Programming 1 July 21st 04 05:45 PM
Excel query creates named range Ed Gravley Excel Programming 1 August 19th 03 08:13 PM
Excel query creates named range Dick Kusleika Excel Programming 2 August 18th 03 06:49 PM


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