Jagwarman
asked on
VBA to delete range of cells in row NOT entire row
I am using a Macro which deletes the entire row but I need to change this to only delete V, W, X and Y within the row. Can this code be changed to do this?
Cells(lngRow - 1, 4).EntireRow.Delete
Thanks
Cells(lngRow - 1, 4).EntireRow.Delete
Thanks
ASKER
Hi Macroshadow
It's not working what it is doing is putting a space between them like this
7001 12/08/2016 252.282 JK5 JWK MFS STMT 11-08-16
7001 12/08/2016 4.671 JK5 JWK MFS STMT 11-08-16
but the original gave me one line like this
7001 12/08/2016 256.953 JK5 JWK MFS STMT 11-08-16
Regards
Jagwarman
It's not working what it is doing is putting a space between them like this
7001 12/08/2016 252.282 JK5 JWK MFS STMT 11-08-16
7001 12/08/2016 4.671 JK5 JWK MFS STMT 11-08-16
but the original gave me one line like this
7001 12/08/2016 256.953 JK5 JWK MFS STMT 11-08-16
Regards
Jagwarman
Can you upload a sample file?
These rows replace Cells(lngRow - 1, 4).EntireRow.Delete:
Cells(lngRow - 1, 22).Value = ""
Cells(lngRow - 1, 23).Value = ""
Cells(lngRow - 1, 24).Value = ""
Cells(lngRow - 1, 25).Value = ""
ASKER
File attached. Originally I was using B-E but now need to use V-Y as per the attached file
Thanks
Find-and-Move-JK.xlsm
Thanks
Find-and-Move-JK.xlsm
You asked to delete cells V, W, X and Y, that is exactly what the code does.
Tested on your sample file.
Tested on your sample file.
ASKER
Hi MacroShadow.
In my message to you I referred you back to the Macro solution you provided me with and said :
last line of code is
23: Cells(lngRow - 1, 4).EntireRow.Delete
unfortunately I have had to make changes to our file and instead of deleting the whole row only want to delete V,W,X and Y
So as the last line of your code deletes the whole row I asked can you instead change it so that it only deletes V,W,X and Y but still it needs to perform the other part of the macro which it does perfectly prior to deleting the whole row.
I am sorry if I misled
In my message to you I referred you back to the Macro solution you provided me with and said :
last line of code is
23: Cells(lngRow - 1, 4).EntireRow.Delete
unfortunately I have had to make changes to our file and instead of deleting the whole row only want to delete V,W,X and Y
So as the last line of your code deletes the whole row I asked can you instead change it so that it only deletes V,W,X and Y but still it needs to perform the other part of the macro which it does perfectly prior to deleting the whole row.
I am sorry if I misled
I must be missing something...
The only thing to change is replace
The only thing to change is replace
Cells(lngRow - 1, 4).EntireRow.Delete
withCells(lngRow - 1, 22).Value = ""
Cells(lngRow - 1, 23).Value = ""
Cells(lngRow - 1, 24).Value = ""
Cells(lngRow - 1, 25).Value = ""
Keep the rest of the code, it will do whatever it is supposed to do.
ASKER
not working for me, very odd will look again tomorrow.
ASKER
Hi MacroShadow,
I have checked this at home and at work and cannot get it to work for me. I am off now for a weeks vacation but will do some more checking when I get back.
I have checked this at home and at work and cannot get it to work for me. I am off now for a weeks vacation but will do some more checking when I get back.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window