.Delete Shift:=xlUp is deleting the whole row???

TAPS_MikeDion

Well-known Member
Joined
Aug 14, 2009
Messages
622
Office Version
  1. 2011
Platform
  1. MacOS
Hi people,
I'm going nuts trying to figure out why this code is deleting the entire row instead of just the selected range. I even recorded a macro to see if I was doing something wrong and the macro that was recorded was basically identical to what I have, and it still deletes the whole row.

For this example assume the following variables:

wSheet = "ZIP Codes"
ZIP = "G"
City = "H"
dRange = 6

Code:
Sheets(wSheet).Range(ZIP & dRange & ":" & City & dRange).Delete Shift:=xlUp

Thanks in advance. ;)
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Does
Code:
MsgBox Sheets(wSheet).Range(ZIP & dRange & ":" & City & dRange).Address
immediatly before that line show the expected address?
 
Upvote 0
Sorry to bother you Mike, I found my mistake. When I had worked on this previously I had an ELSE statement that applied to all of my CASE statements, with the exception of the one I posted about. After the ELSE statement I had Sheets(wSheet).Rows(ComboBox1.ListIndex + 2).Delete xlShiftUp and then it jumped down to the .Delete Shift:=xlUp I was questioning; it was doing a double delete.

After going back in the code I realized I needed to add If AddDel <> 2 after the ELSE statement. Everything works now.

Thanks for trying to help! :cool:
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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