Macros in Excel 2010

Alabama Man

New Member
Joined
Jan 5, 2010
Messages
9
How can I record following functions in Macro:
(1) Insert a column
(2) Use 'IF' function

The only macros I could record and use later were simple addition and subtarction.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
You can record the insert part by clicking Developer on the ribbon, then click record macro, select the column where you want to insert by clicking on the column designation letter (i.e. A, B, C, etc.), then right click and select 'Insert' from the pop up menu. The insertion is now recorded.
The If statement you would need to write in at the point in the macro where it is logical to do so. Simple If statements like"
Code:
With ActiveSheet 'Use Sheets("Sheetname"<SHEET.NAME>) format where possible
 If .Range("A2") <> .Range("B2") Then
  MsgBox "Not Equal"
 Else
  MsgBox "Equal"
 End If
End With
Can be inserted anywhere in the code.
 
Last edited:

Alabama Man

New Member
Joined
Jan 5, 2010
Messages
9
You can record the insert part by clicking Developer on the ribbon, then click record macro, select the column where you want to insert by clicking on the column designation letter (i.e. A, B, C, etc.), then right click and select 'Insert' from the pop up menu. The insertion is now recorded.
The If statement you would need to write in at the point in the macro where it is logical to do so. Simple If statements like"
Code:
With ActiveSheet 'Use Sheets("Sheetname"<SHEET.NAME>) format where possible
 If .Range("A2") <> .Range("B2") Then
  MsgBox "Not Equal"
 Else
  MsgBox "Equal"
 End If
End With
Can be inserted anywhere in the code.

Thre is no easier method. So if I understand correctly, Macros do not record the functions directly, you have to copy the programmed coding.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,833
Office Version
  1. 2010
Platform
  1. Windows
The recorder can do no more than record what you do in the user interface.
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

Thre is no easier method. So if I understand correctly, Macros do not record the functions directly, you have to copy the programmed coding.

I don't think I implied that. There are certain things the recorder cannot record because that particular portion of code is dependent on human rekoning and the recorder facility was not designed to handle that. But, as shg says, it can do more than what you do in the user interface. There are turtorials on using the recorder if you browse the web, you can probably find a free one that will help you out.
 

Alabama Man

New Member
Joined
Jan 5, 2010
Messages
9
I don't think I implied that. There are certain things the recorder cannot record because that particular portion of code is dependent on human rekoning and the recorder facility was not designed to handle that. But, as shg says, it can do more than what you do in the user interface. There are turtorials on using the recorder if you browse the web, you can probably find a free one that will help you out.

Thanks,
 

gardnertoo

Well-known Member
Joined
Jul 24, 2007
Messages
938
When you say you want to record "use the IF function", are you wanting to record what it looks like to use a cell formula containing an IF statement? You can do that by typing such a formula in a cell during the recording. You will end up with a line of code that looks something like this:
Code:
ActiveCell.FormulaR1C1 = "=IF(RAND()>0.5,""Big"",""Small"")"
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,826
Messages
5,855,875
Members
431,771
Latest member
CoryMelth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top