Macro acting like double click

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Macro acting like double click

Post by YasserKhalil »

Hello everyone
I have range("A1:A100") and I need for some reason to double click each cell in this range
Select A1 and then double click inside the cell then press enter and do the same with A2 and so on
I know it is weird request but I need it
How to double click the cell using vba ?

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

Do the cells contain formulas or values? If they contain values, a quick way to simulate double-clicking the cells and pressing Enter is

Code: Select all

    With Range("A1:A100")
        .Value = .Value
    End With
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

Thanks a lot Mr. HansV
But I already tested that but it is not the required
I need something like edit mode ..
I have tried your trick before posting the thread but the results were not as expected too .. It is a problem of dealing with dates .. and it is based on regional settings

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

What do the dates currently look like?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

The date are Hijri dates like that
30/9/1437

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

Does this work? (I have no experience with Hijri dates):

Code: Select all

Sub ProcessDates()
    Range("A1:A100").TextToColumns DataType:=xlDelimited, _
        Tab:=False, Semicolon:=False, Comma:=False, Space:=False, Other:=False, _
        FieldInfo:=Array(1, xlDMYFormat)
End Sub
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

Thanks again Mr. HansV for your reply
It doesn't affect the value to be updated with UDF function. To make the UDF function works well I have to double click each cell in the range
So I was searching for a code that I can loop each cell and double click the cells instead of doing that manually

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

Do you mean that the cells contain formulas?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

No the cells in A1:A100 have Hijri dates and there is UDF function that convert these dates to Gregorian dates ..
The function works well .. the problem is in the dates themselves .. It works well if I double click the cell itself
Thanks a lot for following up the issue

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

How about this?

Code: Select all

Sub ProcessDates()
    ActiveSheet.Calculate
End Sub
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

Thanks a lot for all your replies Mr. HansV
In fact I am searching to edit mode each cell to have correct results as I tested your last trick and it has no effect ..
Please guide me how to edit each cell using loops

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

Could you attach a small sample workbook that contains the UDF and some Hijri dates?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

I can't really upload this workbook and when trying to type similar data with Hijri dates everything is ok ..Even if I copied it to the new workbook it works well
It seems that the problem is that these dates are copied from external source so there's a problem

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

I'm afraid I'm out of ideas.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

Thank you very very much for all your great ideas
I tested this and somewhat working for me

Code: Select all

Sub Test()
    Dim I As Long

    For I = 1 To 100
        Cells(I, 1).Select
        SendKeys "{F2}"
        SendKeys "{Enter}"
    Next I
End Sub
Is that right way?

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro acting like double click

Post by HansV »

SendKeys is notoriously unreliable, but if it works for you, that's fine. You can combine

Code: Select all

        SendKeys "{F2}"
        SendKeys "{Enter}"
to

Code: Select all

        SendKeys "{F2}{Enter}"
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Macro acting like double click

Post by YasserKhalil »

Thank you very much for great help and for your patience
Best and kind regards

User avatar
Sam1085
3StarLounger
Posts: 318
Joined: 23 Aug 2016, 07:43
Location: Sri Lanka

Re: Macro acting like double click

Post by Sam1085 »

HansV wrote:SendKeys is notoriously unreliable
Yah.. That's true. Per my experiences, Sendkeys method will be depending on device performance, application speed and more... But it's great way for automate some works!
-Sampath-