going from one workbook to another in vba

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
okay, so why does the code below set the two ranges (bold code) on the active workbook INSTEAD of wbMaster



Code:
Sub AdjustJPMPLforFutures()
Dim wbMaster As Workbook, wbSource As Workbook
Dim strTrader As String, lFuturesPL As Long, lEquityPL As Long
Dim dDate As Date, rngTemp As Range, rngTraders As Range, rngDates As Range
Dim iTraderPLOffset As Integer, cCell As Range, dCell As Range, x As Integer

x = 1
Set wbMaster = ThisWorkbook
With wbMaster
    [B]Set rngTraders = Range(Range("$A$2"), Range("$A$2").End(xlDown))
    Set rngDates = Range(Range("$B$1"), Range("$B$1").End(xlToRight))[/B]
End With
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Thomas

Your With is basically ineffective, none of the Range references within it actually refer to it.

Stick a dot in front of each instance of Range and see if that works.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,787
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top