#1
|
|||
|
|||
The set range is unexpectedly changed.
I have written a macro that in part of it, I set the selection (for example, range” AD4 to BC 11”) to” T1” and then make a copy of this selection and paste it in another range (for example, range” BD4 to CC 11”) and then set the new range to another variable. (for example,T4). Now my problem is when I set T4, the T1 unexpectedly is no longer the old selection (range” AD1 to BC 11”) but has converted to the range I have assigned it to T4 (” BD4 to CC 11”.see the excel attachment. . The code is assigned to blue circle). Can you guide me on this issue? |
#2
|
||||
|
||||
By inserting cells with
Selection.Insert Shift:=xlToRight you have moved your t1 range to the right. If those cells had values, they too would move to the right. Maybe this will show you what goes on and what you can do. Step through the code with F8 on the keyboard: Code:
Sub monthprocess() Dim t1 As Range, tNew As Range Set t1 = Selection Selection.Insert Shift:=xlToRight Set tNew = Selection 'because the newly inserted range is selected t1.Select tNew.Select End Sub |
#3
|
|||
|
|||
Thank you. I got it.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copy/paste into Excel Pro 2013 wraps a row unexpectedly | mgl_8 | Excel | 1 | 04-30-2018 11:26 PM |
Formats in text boxes in Word 2016 changing unexpectedly | PugwashAtNPEU | Word | 4 | 05-04-2017 05:53 AM |
HELP! Excel background color changing unexpectedly | Doug Needham | Excel | 0 | 12-08-2016 08:22 AM |
Outlook 2010 unexpectedly closes | herby325 | Outlook | 0 | 07-06-2016 08:44 AM |
Project closes unexpectedly | preetsp | Project | 3 | 04-22-2014 06:50 AM |