ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   i'm looking for VB code that does the same as hitting F2 in excel (https://www.excelbanter.com/excel-programming/371996-im-looking-vbulletin-code-does-same-hitting-f2-excel.html)

DN

i'm looking for VB code that does the same as hitting F2 in excel
 
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula

witek

i'm looking for VB code that does the same as hitting F2 in excel
 
dn wrote:
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula




Application.SendKeys "{F2}"

DN

i'm looking for VB code that does the same as hitting F2 in ex
 
Many thanks, can you pls let me know what's the key name for "Enter"
i have tried :
Application.SendKeys "{F2}"
Application.SendKeys "{Enter}"
and it doesn't work

rgds, david


"witek" wrote:

dn wrote:
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula




Application.SendKeys "{F2}"


Dave Peterson

i'm looking for VB code that does the same as hitting F2 in ex
 
I don't know what you're doing, but sending keystrokes is not usually a good way
to do things.

Maybe:

with activecell
.value = .value
'or
.formula = .formula
end with

There may be much better ways of doing what you need.

dn wrote:

Many thanks, can you pls let me know what's the key name for "Enter"
i have tried :
Application.SendKeys "{F2}"
Application.SendKeys "{Enter}"
and it doesn't work

rgds, david

"witek" wrote:

dn wrote:
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula




Application.SendKeys "{F2}"


--

Dave Peterson

DN

i'm looking for VB code that does the same as hitting F2 in ex
 
Many thanks, this worked perfectly.
in a nut shell, i imported dates into excel in dd/mm/yy , for some reason
excel read it as if it was text and not a number, however, i found out that
if you just used F2 and Enter, it was able to read it as a number so i was
trying to do this through a macro. your proposal worked just fine.
many thanks

"Dave Peterson" wrote:

I don't know what you're doing, but sending keystrokes is not usually a good way
to do things.

Maybe:

with activecell
.value = .value
'or
.formula = .formula
end with

There may be much better ways of doing what you need.

dn wrote:

Many thanks, can you pls let me know what's the key name for "Enter"
i have tried :
Application.SendKeys "{F2}"
Application.SendKeys "{Enter}"
and it doesn't work

rgds, david

"witek" wrote:

dn wrote:
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula



Application.SendKeys "{F2}"


--

Dave Peterson


Dave Peterson

i'm looking for VB code that does the same as hitting F2 in ex
 
Be careful.

If I do this kind of thing with my USA settings (mdy order), I may end up with
dates--but they may not be the ones I want.

For instance:
01/02/03
would change to
January 2, 2003
for me.

If your windows regional settings have your short date in dmy format, you should
be ok. But you may want to make a note of a value and then do your conversion.
Then give that cell an unambiguous date format (mmmm dd, yyyy) to see if it's
what you expect.

I like to do this if my "dates" are in a single column
select the column
data|text to columns
fixed width (remove all lines)
and choose date dmy (to match the data)
and finish up.

If I need a macro, I'd record one when I did it manually.

dn wrote:

Many thanks, this worked perfectly.
in a nut shell, i imported dates into excel in dd/mm/yy , for some reason
excel read it as if it was text and not a number, however, i found out that
if you just used F2 and Enter, it was able to read it as a number so i was
trying to do this through a macro. your proposal worked just fine.
many thanks

"Dave Peterson" wrote:

I don't know what you're doing, but sending keystrokes is not usually a good way
to do things.

Maybe:

with activecell
.value = .value
'or
.formula = .formula
end with

There may be much better ways of doing what you need.

dn wrote:

Many thanks, can you pls let me know what's the key name for "Enter"
i have tried :
Application.SendKeys "{F2}"
Application.SendKeys "{Enter}"
and it doesn't work

rgds, david

"witek" wrote:

dn wrote:
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula



Application.SendKeys "{F2}"


--

Dave Peterson


--

Dave Peterson

DN

i'm looking for VB code that does the same as hitting F2 in ex
 
thanks, i didn't think of it but luckily for me the date and my windows are
in dmy format, rgds, david

"Dave Peterson" wrote:

Be careful.

If I do this kind of thing with my USA settings (mdy order), I may end up with
dates--but they may not be the ones I want.

For instance:
01/02/03
would change to
January 2, 2003
for me.

If your windows regional settings have your short date in dmy format, you should
be ok. But you may want to make a note of a value and then do your conversion.
Then give that cell an unambiguous date format (mmmm dd, yyyy) to see if it's
what you expect.

I like to do this if my "dates" are in a single column
select the column
data|text to columns
fixed width (remove all lines)
and choose date dmy (to match the data)
and finish up.

If I need a macro, I'd record one when I did it manually.

dn wrote:

Many thanks, this worked perfectly.
in a nut shell, i imported dates into excel in dd/mm/yy , for some reason
excel read it as if it was text and not a number, however, i found out that
if you just used F2 and Enter, it was able to read it as a number so i was
trying to do this through a macro. your proposal worked just fine.
many thanks

"Dave Peterson" wrote:

I don't know what you're doing, but sending keystrokes is not usually a good way
to do things.

Maybe:

with activecell
.value = .value
'or
.formula = .formula
end with

There may be much better ways of doing what you need.

dn wrote:

Many thanks, can you pls let me know what's the key name for "Enter"
i have tried :
Application.SendKeys "{F2}"
Application.SendKeys "{Enter}"
and it doesn't work

rgds, david

"witek" wrote:

dn wrote:
when you record a macro hitting the F2 in a cell that contains 444, the
result is:
ActiveCell.FormulaR1C1 = "444"
i would like the code just to record the action of hitting the F2 not of
writing the existing cell formula



Application.SendKeys "{F2}"


--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 08:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com