![]() |
|
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Jun 2003
Location: Boca Raton, Florida
Posts: 10
|
Hello, I would like to know how to record the following macro to repeat until it reaches a blank cell: Double click in a cell and then hit enter.
I am not familiar with VBA, and have tried to use the Relative Reference button while recording. I would really appreciate any help, thanks! |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
What do you want to do to the cells? Double click and then enter?
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Dec 2003
Location: Brampton
Posts: 3,185
|
This code should cycle through each cell in the range A1 to the last data value in column A. If it finds a blank cell, it will end.
sub Repeat() Dim R as range for each R in activesheet("A1",range("A65000").end(xlup)) If r.value ="" then Exit loop End If Your Code Here Next End Sub |
|
|
|
|
|
#4 |
|
New Member
Join Date: Jun 2003
Location: Boca Raton, Florida
Posts: 10
|
Hi Jacob,
I'm not sure how to respond to you on the message board, but yes, I just want to double click on a cell with a value, and then press enter. Excel requires this to be done when changing the formatting of values. Regards, Steve. |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
You can use application.doubleclick to send a double click, but if you just want to reformat the cell you can do that without a doubleclick
i.e. range("A1").Value = Format(Range("A1").Value,"0.00") So this is just depending on what you specifically want to do. |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,578
|
Quote:
|
|
|
|
|
|
|
#7 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
Quote:
From Excel Help DoubleClick Method See Also Applies To Example Specifics Equivalent to double-clicking the active cell. expression.DoubleClick expression Required. An expression that returns an Application object. Example This example double-clicks the active cell on Sheet1. Worksheets("Sheet1").Activate Application.DoubleClick |
||
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,578
|
And did you test it? Put this in the Sheet1 module:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) MsgBox "Hello" End Sub Doubleclick in Sheet1, and you will see the message box, with the cursor flashing inside the cell you double clicked because now you are in Edit mode. Go to Sheet2 and run the macro you just posted. Do you see the message box pop up now? Do you see the cursor flashing in a cell as if you doubleclicked anything? |
|
|
|
|
|
#9 |
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
So it doesn't trigger the sheet event. It still sends a double click, though excel probably ignores it if the object is a cell. I played with it a bit, and if the onject is a chart it works.
Anyways I gave the OP two possible solutions to try, if neither of those work I am sure he will post back and someone else can help. |
|
|
|
|
|
#10 | ||
|
MrExcel MVP
Join Date: Mar 2004
Location: Belgium 3272 Testelt
Posts: 17,303
|
smoscar,
you asked at the start Quote:
Quote:
Guys experts, are we not losing focus here ? or do I really miss something here, then apologise smoscar, do you want to format a given range just once or do you need a macro to format several times ? which range would you like to format ? just hoping to help in a simple way regards, Erik
__________________
I love Jesus piano improvisation Abba Father email Erik founder of DRAFT my free Addins Table-It download & info Formula Translator 04 |
||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|