End(xlUp), etc. doesn't work unless you are looking at that tab?

Alex0013

Board Regular
Joined
Jul 23, 2014
Messages
158
Office Version
  1. 365
Platform
  1. Windows
Hey All,

Quick question, I have some very basic code copying and pasting from one tab to another, however, for some reason, the Copy doesn't work, unless I'm looking at that tab. If I'm looking at another tab, nothing get's copied. But when I'm looking at the source tab, it works perfectly. Any thoughts? Does End(xlUp) not work unless you are looking at it??
Code:
    Set wsTeams = Sheets("Teams")
    Set wsResult = Sheets("Teams Grid")
    wsTeams.Range(Range("A1"), Range("B" & Rows.Count).End(xlUp)).Copy
    wsResult.Range("B2").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True

Again, the code works perfect if I'm currently on the "Teams" tab. But if I execute the macro from then Teams Grid tab, nothing copies over.

Thoughts?
Thanks!
Alex
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Code:
wsTeams.Range([COLOR="#FF0000"]wsTeams.[/COLOR]Range("A1"), [COLOR="#FF0000"]wsTeams.[/COLOR]Range("B" & Rows.Count).End(xlUp)).Copy

or

Code:
wsTeams.Range("A1:B" & wsTeams.Range("B" & Rows.count).End(xlUp).Row).Copy
 
Last edited:
Upvote 0
Ah....now I feel dumb...thanks so much! For some reason my brain was telling me I didn't need to identify each Range...but of course I do...

Thanks so much!
 
Upvote 0

Forum statistics

Threads
1,225,754
Messages
6,186,826
Members
453,377
Latest member
JoyousOne

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