Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Delete Single Cell - VBS

Posted on 2011-10-12
Medium Priority
Last Modified: 2012-05-12
Is there a way to delete a SINGLE CELL in an Excel worksheet using VBS?  I want it to delete the cells and move whatever data is to the right of it into that cell.

I've searched around, but it appears you can only delete ROWs.  If that's the case, I'll have to draft the logic that moves the cell contents to the left.

Thanks for whatever help you can be.
Question by:BMIT
  • 2
LVL 65

Accepted Solution

RobSampson earned 2000 total points
ID: 36958952
Hi, in VBS, this should work.


Const xlToLeft = -4159
Set objExcel = CreateObject("Excel.Application")
Set objWB = objExcel.Workbooks.Open("C:\MyBook.xls", False, False)
Set objSheet = objWB.Sheets(1)
objSheet.Range("C3").Delete xlToLeft

Open in new window


Author Closing Comment

ID: 36963110
An eloquent and articulate answer.  I had forgotten that you had to use .Range to delete cells, even if single ones.

LVL 65

Expert Comment

ID: 36965458
No worries. Thanks for the grade.


Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question