ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help me figure out this buG? (https://www.excelbanter.com/excel-programming/298516-help-me-figure-out-bug.html)

majikman[_23_]

help me figure out this buG?
 
my code below fails at the line rTotal.Select. I don't understand why i
won't let me select that code when I run it. However, it works fine i
i step into the function through the debugger. anyone have som
suggestsion?

Set rBally = Range("D10:O12")
Set rBio = Range("D20:O22")
Set rCP = Range("D30:O32")
Set rFS = Range("D40:O42")
Set rLabrada = Range("D50:O52")
Set rMT = Range("D60:O62")
Set rPE = Range("D70:O72")
Set rRP = Range("D80:O82")
Set rSFU = Range("D90:O92")
Set rSFA = Range("D100:O102")
Set rUni = Range("D110:O112")

Workbooks("Bars 2004.xls").Worksheets("Total Bars MASTER").Visibl
= xlSheetVisible
Workbooks.Open ("C:\Documents and Settings\Adam\Desktop\Monthl
Sales\Master.xls")


Workbooks("Bars 2004.xls").Worksheets("Total Bar
MASTER").Activate
Set rTotal = Union(rBally, rBio, rCP, rFS, rLabrada, rMT, rPE, rRP
rSFU, rSFA, rUni)
rTotal.Select
Call CopyPast

--
Message posted from http://www.ExcelForum.com


Frank Kabel

help me figure out this buG?
 
Hi
not tested but try the following (a bit more specific
which workbook/worksheet to access. note: In most cases a
selection/activation is not required):

Sub foo()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Dim wks As Worksheet

Set wbk1 = Workbooks("Bars 2004.xls")
Set wks1 = wbk1.Worksheets("Total Bars MASTER")
With wks1
Set rBally = .Range("D10:O12")
Set rBio = .Range("D20:O22")
Set rCP = .Range("D30:O32")
Set rFS = .Range("D40:O42")
Set rLabrada = .Range("D50:O52")
Set rMT = .Range("D60:O62")
Set rPE = .Range("D70:O72")
Set rRP = .Range("D80:O82")
Set rSFU = .Range("D90:O92")
Set rSFA = .Range("D100:O102")
Set rUni = .Range("D110:O112")
End With
wks1.Visible = xlSheetVisible

Workbooks.Open ("C:\Documents and
Settings\Adam\Desktop\Monthly Sales\Master.xls")
Set wbk2 = ActiveWorkbook

wbk1.Activate
wks1.Activate

Set rTotal = Union(rBally, rBio, rCP, rFS, rLabrada, rMT,
rPE, rRP, rSFU, rSFA, rUni)
rTotal.Select
Call CopyPaste
End Sub

-----Original Message-----
my code below fails at the line rTotal.Select. I don't

understand why it
won't let me select that code when I run it. However, it

works fine if
i step into the function through the debugger. anyone

have some
suggestsion?

Set rBally = Range("D10:O12")
Set rBio = Range("D20:O22")
Set rCP = Range("D30:O32")
Set rFS = Range("D40:O42")
Set rLabrada = Range("D50:O52")
Set rMT = Range("D60:O62")
Set rPE = Range("D70:O72")
Set rRP = Range("D80:O82")
Set rSFU = Range("D90:O92")
Set rSFA = Range("D100:O102")
Set rUni = Range("D110:O112")

Workbooks("Bars 2004.xls").Worksheets("Total Bars

MASTER").Visible
= xlSheetVisible
Workbooks.Open ("C:\Documents and

Settings\Adam\Desktop\Monthly
Sales\Master.xls")


Workbooks("Bars 2004.xls").Worksheets("Total Bars
MASTER").Activate
Set rTotal = Union(rBally, rBio, rCP, rFS, rLabrada, rMT,

rPE, rRP,
rSFU, rSFA, rUni)
rTotal.Select
Call CopyPaste


---
Message posted from http://www.ExcelForum.com/

.


majikman[_24_]

help me figure out this buG?
 
agh, that helped me out. i hate when i make stupid errors like that.
just didn't clarify when i was setting all the ranges which is why i
didn't work. but thanks for your help. i spent the last hou
overlooking that

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 07:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com