Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default how to delete cells without shifting and rows/columns

Hi,
I've tried to use "clearcontents" & "clear" but neither works the way I
wanted (I was using a 3rd party add-in, the add-in is disabled unless
"delete" is used. The down side is that would shift all my controls, too
(putting them all into the upper left corner). However, if I manually select
the whole worksheet, and press the delete key, that seems to work exactly
what I want (which is to clear all the contents, and yet leaving all the
controls where there are without shifting).

Please help
Jeff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to delete cells without shifting and rows/columns

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents - and you say that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but neither works the way I
wanted (I was using a 3rd party add-in, the add-in is disabled unless
"delete" is used. The down side is that would shift all my controls, too
(putting them all into the upper left corner). However, if I manually

select
the whole worksheet, and press the delete key, that seems to work exactly
what I want (which is to clear all the contents, and yet leaving all the
controls where there are without shifting).

Please help
Jeff



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to delete cells without shifting and rows/columns

Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is it a way to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in sheet

Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And have it as

the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are cleared, but the
add-in button is still gray out. One thing I noticed is when I hit

the
delete key manually, a msgbox pops up w/ the msg (that doesn't happen

when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that retrieves

data
from an external source. do you want to delete the query in addition

to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents - and you

say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but neither works

the
way I
wanted (I was using a 3rd party add-in, the add-in is disabled

unless
"delete" is used. The down side is that would shift all my

controls,
too
(putting them all into the upper left corner). However, if I

manually
select
the whole worksheet, and press the delete key, that seems to work

exactly
what I want (which is to clear all the contents, and yet leaving

all
the
controls where there are without shifting).

Please help
Jeff








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to delete cells without shifting and rows/columns

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is it a way

to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in sheet

Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And have it as

the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are cleared, but

the
add-in button is still gray out. One thing I noticed is when I hit

the
delete key manually, a msgbox pops up w/ the msg (that doesn't

happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that retrieves

data
from an external source. do you want to delete the query in

addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents - and you

say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but neither works

the
way I
wanted (I was using a 3rd party add-in, the add-in is disabled

unless
"delete" is used. The down side is that would shift all my

controls,
too
(putting them all into the upper left corner). However, if I

manually
select
the whole worksheet, and press the delete key, that seems to

work
exactly
what I want (which is to clear all the contents, and yet leaving

all
the
controls where there are without shifting).

Please help
Jeff










  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default how to delete cells without shifting and rows/columns

Tom,
DoEvents doesn't work.
It doesn't matter if the dialog box pops up or not. If all possible I'd
rather pass in "yes" so the dialog box doesn't show up at all.

Thanks

"Tom Ogilvy" wrote:

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is it a way

to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in sheet

Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And have it as

the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are cleared, but

the
add-in button is still gray out. One thing I noticed is when I hit

the
delete key manually, a msgbox pops up w/ the msg (that doesn't

happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that retrieves

data
from an external source. do you want to delete the query in

addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents - and you

say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but neither works

the
way I
wanted (I was using a 3rd party add-in, the add-in is disabled

unless
"delete" is used. The down side is that would shift all my

controls,
too
(putting them all into the upper left corner). However, if I

manually
select
the whole worksheet, and press the delete key, that seems to

work
exactly
what I want (which is to clear all the contents, and yet leaving

all
the
controls where there are without shifting).

Please help
Jeff













  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to delete cells without shifting and rows/columns

Sub Test1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2",,True
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
Application.displayAlerts = True
End Sub

Should suppress the popup and answer Yes.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Tom,
DoEvents doesn't work.
It doesn't matter if the dialog box pops up or not. If all possible

I'd
rather pass in "yes" so the dialog box doesn't show up at all.

Thanks

"Tom Ogilvy" wrote:

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select

cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is it a

way
to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in

sheet
Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And have it

as
the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are cleared,

but
the
add-in button is still gray out. One thing I noticed is when I

hit
the
delete key manually, a msgbox pops up w/ the msg (that doesn't

happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that

retrieves
data
from an external source. do you want to delete the query in

addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents - and

you
say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but neither

works
the
way I
wanted (I was using a 3rd party add-in, the add-in is

disabled
unless
"delete" is used. The down side is that would shift all my
controls,
too
(putting them all into the upper left corner). However, if

I
manually
select
the whole worksheet, and press the delete key, that seems to

work
exactly
what I want (which is to clear all the contents, and yet

leaving
all
the
controls where there are without shifting).

Please help
Jeff













  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default how to delete cells without shifting and rows/columns

the message box still appears.


"Tom Ogilvy" wrote:

Sub Test1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2",,True
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
Application.displayAlerts = True
End Sub

Should suppress the popup and answer Yes.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Tom,
DoEvents doesn't work.
It doesn't matter if the dialog box pops up or not. If all possible

I'd
rather pass in "yes" so the dialog box doesn't show up at all.

Thanks

"Tom Ogilvy" wrote:

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select

cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is it a

way
to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in

sheet
Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And have it

as
the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are cleared,

but
the
add-in button is still gray out. One thing I noticed is when I

hit
the
delete key manually, a msgbox pops up w/ the msg (that doesn't
happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that

retrieves
data
from an external source. do you want to delete the query in
addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents - and

you
say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but neither

works
the
way I
wanted (I was using a 3rd party add-in, the add-in is

disabled
unless
"delete" is used. The down side is that would shift all my
controls,
too
(putting them all into the upper left corner). However, if

I
manually
select
the whole worksheet, and press the delete key, that seems to
work
exactly
what I want (which is to clear all the contents, and yet

leaving
all
the
controls where there are without shifting).

Please help
Jeff














  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to delete cells without shifting and rows/columns

This worked for me.

Sub AAAATest1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime Now + TimeValue("00:00:01"), "Test2", , True
SendKeys "{DEL}~", False
End Sub
Sub Test2()
Worksheets("Main").Range("B1").Select
Application.DisplayAlerts = True
End Sub

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
the message box still appears.


"Tom Ogilvy" wrote:

Sub Test1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2",,True
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
Application.displayAlerts = True
End Sub

Should suppress the popup and answer Yes.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Tom,
DoEvents doesn't work.
It doesn't matter if the dialog box pops up or not. If all

possible
I'd
rather pass in "yes" so the dialog box doesn't show up at all.

Thanks

"Tom Ogilvy" wrote:

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select

cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is

it a
way
to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in

sheet
Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And

have it
as
the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are

cleared,
but
the
add-in button is still gray out. One thing I noticed is

when I
hit
the
delete key manually, a msgbox pops up w/ the msg (that

doesn't
happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that

retrieves
data
from an external source. do you want to delete the query in
addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents -

and
you
say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but

neither
works
the
way I
wanted (I was using a 3rd party add-in, the add-in is

disabled
unless
"delete" is used. The down side is that would shift all

my
controls,
too
(putting them all into the upper left corner). However,

if
I
manually
select
the whole worksheet, and press the delete key, that

seems to
work
exactly
what I want (which is to clear all the contents, and yet

leaving
all
the
controls where there are without shifting).

Please help
Jeff
















  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default how to delete cells without shifting and rows/columns

Thanks alot for your help.
Yes, it does work, i left off the "~" on sendkeys so it didn't emulate
pressing enter.


"Tom Ogilvy" wrote:

This worked for me.

Sub AAAATest1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime Now + TimeValue("00:00:01"), "Test2", , True
SendKeys "{DEL}~", False
End Sub
Sub Test2()
Worksheets("Main").Range("B1").Select
Application.DisplayAlerts = True
End Sub

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
the message box still appears.


"Tom Ogilvy" wrote:

Sub Test1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2",,True
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
Application.displayAlerts = True
End Sub

Should suppress the popup and answer Yes.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Tom,
DoEvents doesn't work.
It doesn't matter if the dialog box pops up or not. If all

possible
I'd
rather pass in "yes" so the dialog box doesn't show up at all.

Thanks

"Tom Ogilvy" wrote:

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select
cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line. Is

it a
way
to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put that in
sheet
Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And

have it
as
the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are

cleared,
but
the
add-in button is still gray out. One thing I noticed is

when I
hit
the
delete key manually, a msgbox pops up w/ the msg (that

doesn't
happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query that
retrieves
data
from an external source. do you want to delete the query in
addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses ClearContents -

and
you
say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in message
...
Hi,
I've tried to use "clearcontents" & "clear" but

neither
works
the
way I
wanted (I was using a 3rd party add-in, the add-in is
disabled
unless
"delete" is used. The down side is that would shift all

my
controls,
too
(putting them all into the upper left corner). However,

if
I
manually
select
the whole worksheet, and press the delete key, that

seems to
work
exactly
what I want (which is to clear all the contents, and yet
leaving
all
the
controls where there are without shifting).

Please help
Jeff

















  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to delete cells without shifting and rows/columns

hmmm
the point of the enter is to drop the dialog without user intervention -
otherwise we are back to 4 or 5 posts ago. But whatever.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks alot for your help.
Yes, it does work, i left off the "~" on sendkeys so it didn't emulate
pressing enter.


"Tom Ogilvy" wrote:

This worked for me.

Sub AAAATest1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime Now + TimeValue("00:00:01"), "Test2", , True
SendKeys "{DEL}~", False
End Sub
Sub Test2()
Worksheets("Main").Range("B1").Select
Application.DisplayAlerts = True
End Sub

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
the message box still appears.


"Tom Ogilvy" wrote:

Sub Test1()
Application.DisplayAlerts = False
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2",,True
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
Application.displayAlerts = True
End Sub

Should suppress the popup and answer Yes.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Tom,
DoEvents doesn't work.
It doesn't matter if the dialog box pops up or not. If all

possible
I'd
rather pass in "yes" so the dialog box doesn't show up at all.

Thanks

"Tom Ogilvy" wrote:

Screwed up the Ontime command. Should be

Application.OnTime now + TimeValue("00:00:02"),"Test2",,True

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Two things you can try
Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
DoEvents
Worksheets("Main").Range("B1").Select
End Sub

or

Sub Test1()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
Application.OnTime now + TimeValue("00:00:02"),"Test2"
SendKeys "{DEL}", False
End sub

Sub Test2
Worksheets("Main").Range("B1").Select
End Sub

I haven't tested either. The appearance of the dialog may

affect
performance - do you really want the dialog to appear.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Thanks Tom,
It only works with "false"
Here is another problem I have, when I tried to select
cell("B1"), I
don't get the prompt.
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
Worksheets("Main").Range("B1").Select

Everything works fine if I comment out the last line.

Is
it a
way
to
put a delay (so I can click yes before set focus to B1?)

Thanks a lot for your help


"Tom Ogilvy" wrote:

I did a Get External Data to the Northwind.mdb and put

that in
sheet
Main.

then went to another sheet and ran this:

Sub AAAAA()
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", False
End Sub

I got the prompt you describe.

I didn't test it with True, so try changing to False. And

have it
as
the
last command in your macro.

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Thanks for trying, it still doesn't work.

Here is my code:
Worksheets("Main").Select
Worksheets("Main").Cells.Select
SendKeys "{DEL}", True

as the codes finished, once again the contents are

cleared,
but
the
add-in button is still gray out. One thing I noticed

is
when I
hit
the
delete key manually, a msgbox pops up w/ the msg (that

doesn't
happen
when
I
use the sendkeys, clear, or clearcontents):
"The range you deleted is associated with a query

that
retrieves
data
from an external source. do you want to delete the

query in
addition
to
the
range? if you click no, ..."


Thanks
Jeff
"Tom Ogilvy" wrote:

Sounds like you need to try using SendKeys.

because if you record this action it uses

ClearContents -
and
you
say
that
doesn't work.

--
Regards,
Tom Ogilvy




"Jeff" wrote in

message

...
Hi,
I've tried to use "clearcontents" & "clear" but

neither
works
the
way I
wanted (I was using a 3rd party add-in, the add-in

is
disabled
unless
"delete" is used. The down side is that would shift

all
my
controls,
too
(putting them all into the upper left corner).

However,
if
I
manually
select
the whole worksheet, and press the delete key, that

seems to
work
exactly
what I want (which is to clear all the contents, and

yet
leaving
all
the
controls where there are without shifting).

Please help
Jeff



















Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shifting rows into columns biggg_fish Excel Discussion (Misc queries) 2 March 28th 07 03:13 AM
Deleting and shifting cells and columns Curt1521 Excel Worksheet Functions 7 May 8th 06 04:14 PM
Delete rows with empty cells in columns B&C Richard Excel Discussion (Misc queries) 3 March 18th 06 12:15 AM
Allow delete/insert cells to del/insrt highlighted rows/columns DOT-TE3 Setting up and Configuration of Excel 1 March 16th 06 10:29 PM
delete columns and rows-cells equalling zero or any selected value Scottie Excel Worksheet Functions 2 May 9th 05 08:47 PM


All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"