Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a rows selection to delete, and using a msgbox I want to ask user to
do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Get a reference to the selection before you pop up the messagebox.
dim rngSel as range set rngSel = selection 'do stuff which might change selection 'operate on rngSel However, msgbox doesn't change the selection for me, so maybe you're doing something else in your code? Tim "MLevesque" wrote in message ... I have a rows selection to delete, and using a msgbox I want to ask user to do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I agree. Below is my experiment. It stays highlighted until I send the right
cursor keystroke whether I delete the row or not. Watch that you are not unintentionally releasing the selection somehow. Roy Dim x As Integer Rows(7).Select x = MsgBox("Really delete this row? Press OK to delete or Cancel to abort.", vbOKCancel + vbExclamation, "Delete Row?") If x = vbOK Then Rows(7).Delete End If SendKeys "{RIGHT}" 'to relase the selection -- (delete .nospam) "Tim Williams" wrote: Get a reference to the selection before you pop up the messagebox. dim rngSel as range set rngSel = selection 'do stuff which might change selection 'operate on rngSel However, msgbox doesn't change the selection for me, so maybe you're doing something else in your code? Tim "MLevesque" wrote in message ... I have a rows selection to delete, and using a msgbox I want to ask user to do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you, but it does not work for me. My code is the following...
if msgbox("Do you really want to delete selected rows?"...) = vbOk then for each rng in selection if rng.row = 10 and rng.row <= 20 then rng.entirerow.delete endif next rng endif "Tim Williams" wrote: Get a reference to the selection before you pop up the messagebox. dim rngSel as range set rngSel = selection 'do stuff which might change selection 'operate on rngSel However, msgbox doesn't change the selection for me, so maybe you're doing something else in your code? Tim "MLevesque" wrote in message ... I have a rows selection to delete, and using a msgbox I want to ask user to do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this:
dim x if msgbox("Do you really want to delete selected rows?"...) = vbOk then Selection.EntireRow.Delete end if Problem with your approach is you can't delete rows without affecting the selection - that causes problems with your loop. Tim. "MLevesque" wrote in message ... Thank you, but it does not work for me. My code is the following... if msgbox("Do you really want to delete selected rows?"...) = vbOk then for each rng in selection if rng.row = 10 and rng.row <= 20 then rng.entirerow.delete endif next rng endif "Tim Williams" wrote: Get a reference to the selection before you pop up the messagebox. dim rngSel as range set rngSel = selection 'do stuff which might change selection 'operate on rngSel However, msgbox doesn't change the selection for me, so maybe you're doing something else in your code? Tim "MLevesque" wrote in message ... I have a rows selection to delete, and using a msgbox I want to ask user to do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I know but I need to verify each row before deletion. I cannot do only a
Selection.EntireRow.Delete "Tim Williams" wrote: Try this: dim x if msgbox("Do you really want to delete selected rows?"...) = vbOk then Selection.EntireRow.Delete end if Problem with your approach is you can't delete rows without affecting the selection - that causes problems with your loop. Tim. "MLevesque" wrote in message ... Thank you, but it does not work for me. My code is the following... if msgbox("Do you really want to delete selected rows?"...) = vbOk then for each rng in selection if rng.row = 10 and rng.row <= 20 then rng.entirerow.delete endif next rng endif "Tim Williams" wrote: Get a reference to the selection before you pop up the messagebox. dim rngSel as range set rngSel = selection 'do stuff which might change selection 'operate on rngSel However, msgbox doesn't change the selection for me, so maybe you're doing something else in your code? Tim "MLevesque" wrote in message ... I have a rows selection to delete, and using a msgbox I want to ask user to do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Everything is ok now. Sorry I did a mistake!
Thank you!! "Tim Williams" wrote: Get a reference to the selection before you pop up the messagebox. dim rngSel as range set rngSel = selection 'do stuff which might change selection 'operate on rngSel However, msgbox doesn't change the selection for me, so maybe you're doing something else in your code? Tim "MLevesque" wrote in message ... I have a rows selection to delete, and using a msgbox I want to ask user to do ok or cancel, but when the msgbox is popup, my rows selection is lost :o( How could I avoid that problem? Thank you! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Returning a cell address in a msgbox, by selection via inputbox Ty | Excel Discussion (Misc queries) | |||
selection and visibility, lost charts | Charts and Charting in Excel | |||
Copy Selection - Transpose Selection - Delete Selection | Excel Discussion (Misc queries) | |||
How do I keep a running total of pounds lost and percentage lost | Excel Discussion (Misc queries) | |||
how change selection when msgbox dialog box on screen? | Excel Programming |