Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Macro recording

Is there a way of recording a macro that will perform the
keystrokes that we do - including editing of cells by
using the "F2" function key.

I am wanting to write a procedure that will edit the
formulae in cells in a workbook ie I want the macro to go
into the cell in a sheet that have formulae in them like
='Sheet1'!A10/'Sheet1'!C10 (say in E10) and replace with
=if(Iserr('Sheet1'!A10/'Sheet1'!C10),0,'Sheet1'!
A10/'Sheet1'!C10).

When trying to do this by recording, the recording seems
to switch off when I go into edit mode. This would be Ok
if I wanted relative copies I can record in "relative
mode", but the formulae I want to edit refer to different
sheets rather than relative references on the same sheet.

Any ideas would be welcome.

TIA
Ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Macro recording

Is there a way of recording a macro that will perform the
keystrokes that we do - including editing of cells by
using the "F2" function key.

No. Excel records the results of what you do, not necessarily the steps
that you perform.

When trying to do this by recording, the recording seems

to switch off when I go into edit mode.

Right. You can neither record nor run macros when in Edit mode.

In Excel you have to "describe" what you want to happen in programming
terms. For example this may be what you want:


Sub a()
Dim CurrFormula As String
CurrFormula = Mid(ActiveCell.Formula, 2) 'Drop "="
ActiveCell.Formula = "=if(Iserr(" & CurrFormula & _
"),0," & CurrFormula & ")"
End Sub


--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Macro recording

Thanks a million Jim,

Your solution seems absolute magic! And yet it seems so
wonderfully simple - makes me wonder why I hadn't thought
of it. That's probably why you're MVP!

Thanks again.

Ron
-----Original Message-----
Is there a way of recording a macro that will perform

the
keystrokes that we do - including editing of cells by
using the "F2" function key.

No. Excel records the results of what you do, not

necessarily the steps
that you perform.

When trying to do this by recording, the recording seems

to switch off when I go into edit mode.

Right. You can neither record nor run macros when in

Edit mode.

In Excel you have to "describe" what you want to happen

in programming
terms. For example this may be what you want:


Sub a()
Dim CurrFormula As String
CurrFormula = Mid(ActiveCell.Formula, 2) 'Drop "="
ActiveCell.Formula = "=if(Iserr(" & CurrFormula & _
"),0," & CurrFormula & ")"
End Sub


--
Jim Rech
Excel MVP


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Macro recording

That's probably why you're MVP!

Oh, my head! Must stop the swelling!<g

--
Jim Rech
Excel MVP


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Macro recording

Ron,
this code when run will change the formulas in the selection from
=The formula to
=if(iserror(The formula),"",The formula)

Sub Addiserror()
Dim cell As Range
For Each cell In Selection
If cell.HasFormula Then
cell.Formula = "=if(iserror(" & _
Replace(cell.Formula, "=", "", 1, 1, vbTextCompare) & _
"),""""," & _
Replace(cell.Formula, "=", "", 1, 1, vbTextCompare) & ")"
End If
Next cell
End Sub

HTH
Cecil

"Ron McCormick" wrote in message
...
Is there a way of recording a macro that will perform the
keystrokes that we do - including editing of cells by
using the "F2" function key.

I am wanting to write a procedure that will edit the
formulae in cells in a workbook ie I want the macro to go
into the cell in a sheet that have formulae in them like
='Sheet1'!A10/'Sheet1'!C10 (say in E10) and replace with
=if(Iserr('Sheet1'!A10/'Sheet1'!C10),0,'Sheet1'!
A10/'Sheet1'!C10).

When trying to do this by recording, the recording seems
to switch off when I go into edit mode. This would be Ok
if I wanted relative copies I can record in "relative
mode", but the formulae I want to edit refer to different
sheets rather than relative references on the same sheet.

Any ideas would be welcome.

TIA
Ron





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording Macro carrera Excel Discussion (Misc queries) 2 March 14th 08 02:07 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Recording Macro Connie Martin Excel Worksheet Functions 0 November 25th 05 05:41 PM
Recording a macro ... Marss Excel Discussion (Misc queries) 3 February 17th 05 07:26 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"