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

TAPS_MikeDion

Well-known Member
Joined
Aug 14, 2009
Messages
524
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. ;)
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,906
Does
Code:
MsgBox Sheets(wSheet).Range(ZIP & dRange & ":" & City & dRange).Address
immediatly before that line show the expected address?
 

TAPS_MikeDion

Well-known Member
Joined
Aug 14, 2009
Messages
524
Office Version
  1. 2011
Platform
  1. MacOS
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:
 

Watch MrExcel Video

Forum statistics

Threads
1,122,521
Messages
5,596,653
Members
414,083
Latest member
Mrsash

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
Top