
Delete a row in Excel worksheet from VB program
Quote:
> Hi everybody,
> My VB application will generate data to pre-format Excel worksheet. But
> in some situations, I wish to delete a row or a column in the pre-
> format worksheet which I do not want it apppear in the Excel Report.
> How do I code my VB program to perform this task ? May someone help me ?
> Thanks in advance.
> G.H.
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Try this to delete column D:
Columns("D:D").Delete Shift:=xlToLeft
By the way, to figure out VBA code for anything in Excel, use the
Macro Recorder (Tools/Macro/Record New Macro; do whatever you want
to do; hit the Stop button. Then Tolls/Macro/Macros/Edit to see the
VBA code generated). You will usually have to make some small changes,
but this will give you the general idea. When I did the above, it gave
me:
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
I happen to know what using .select and selection. causes Excel to
create a Range object behind the scenes, and Excel won't really close
when the user closes it (as long as the app that created it is still
open), so I don't use them; you can usually put the lines together
and remove the Select stuff.
Robin
nightingale at home don't spamme dammit dot com