ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro code question (https://www.excelbanter.com/excel-programming/305172-re-macro-code-question.html)

Tom Ogilvy

Macro code question
 
ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
ActiveCell.Numberformat = "General"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Application.CutCopyMode = False
Selection.Copy
' Activecell.??? what can I put here to perform what F2 key and enter
does???
ActiveCell.Offset(rowoffset:=1).Select

Should fix it.

if it doesn't then the formula you are pasting may be referring to a cell
formatted as Text. If so, can you change the formatting on that cell?
--
Regards,
Tom Ogilvy

"anderson101" wrote in message
...
I have created a very simple macro to copy the contents of one cell and

paste it in another effectively creating an =If forumla. However, this new
forumla will not "activate?" until I hit the F2 key and hit enter. If
someone can show me the code I can use to automatically perform this
function in any way (F2 then enter), I would be very appreciative! here is
the code I have and the line I am having a problem with:


ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,

SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
' Activecell.??? what can I put here to perform what F2 key and enter

does???
ActiveCell.Offset(rowoffset:=1).Select

Thank you!




anderson101

Macro code question
 
Tom, thank you for your reply. What is happening is that I am creating an =if formula through a series of cell combinations (i.e. combining three cells A1&A2&A3). Then, I'm pasting the value of this combination in a new cell. Of course, it pastes like a value since that is what it is. However, I found that if I hit the F2 key to "edit" the cell and then immediately hit enter, the value realizes it is a formula and calculates accordingly. I was looking for some VB code to automatically perform this F2 and enter process. The purpose is to create a macro that dynamically creates a formula and places the result as desired (by an unsophisticated excel user). Any thoughts?

"Tom Ogilvy" wrote:

ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
ActiveCell.Numberformat = "General"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Application.CutCopyMode = False
Selection.Copy
' Activecell.??? what can I put here to perform what F2 key and enter
does???
ActiveCell.Offset(rowoffset:=1).Select

Should fix it.

if it doesn't then the formula you are pasting may be referring to a cell
formatted as Text. If so, can you change the formatting on that cell?
--
Regards,
Tom Ogilvy

"anderson101" wrote in message
...
I have created a very simple macro to copy the contents of one cell and

paste it in another effectively creating an =If forumla. However, this new
forumla will not "activate?" until I hit the F2 key and hit enter. If
someone can show me the code I can use to automatically perform this
function in any way (F2 then enter), I would be very appreciative! here is
the code I have and the line I am having a problem with:


ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,

SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
' Activecell.??? what can I put here to perform what F2 key and enter

does???
ActiveCell.Offset(rowoffset:=1).Select

Thank you!





Tom Ogilvy

Macro code question
 
ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
Selection.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.formula = ActiveCell.Value
ActiveCell.Offset(rowoffset:=1).Select


--
Regards,
Tom Ogilvy

"anderson101" wrote in message
...
Tom, thank you for your reply. What is happening is that I am creating an

=if formula through a series of cell combinations (i.e. combining three
cells A1&A2&A3). Then, I'm pasting the value of this combination in a new
cell. Of course, it pastes like a value since that is what it is. However,
I found that if I hit the F2 key to "edit" the cell and then immediately hit
enter, the value realizes it is a formula and calculates accordingly. I was
looking for some VB code to automatically perform this F2 and enter process.
The purpose is to create a macro that dynamically creates a formula and
places the result as desired (by an unsophisticated excel user). Any
thoughts?

"Tom Ogilvy" wrote:

ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
ActiveCell.Numberformat = "General"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Application.CutCopyMode = False
Selection.Copy
' Activecell.??? what can I put here to perform what F2 key and enter
does???
ActiveCell.Offset(rowoffset:=1).Select

Should fix it.

if it doesn't then the formula you are pasting may be referring to a

cell
formatted as Text. If so, can you change the formatting on that cell?
--
Regards,
Tom Ogilvy

"anderson101" wrote in message
...
I have created a very simple macro to copy the contents of one cell

and
paste it in another effectively creating an =If forumla. However, this

new
forumla will not "activate?" until I hit the F2 key and hit enter. If
someone can show me the code I can use to automatically perform this
function in any way (F2 then enter), I would be very appreciative! here

is
the code I have and the line I am having a problem with:


ActiveCell.Offset(columnoffset:=1).Select
Selection.Copy
ActiveCell.Offset(columnoffset:=-1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,

SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
' Activecell.??? what can I put here to perform what F2 key and

enter
does???
ActiveCell.Offset(rowoffset:=1).Select

Thank you!








All times are GMT +1. The time now is 03:59 PM.

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