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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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:
Upvote 0
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.
 
Upvote 0
The recorder can do no more than record what you do in the user interface.
 
Upvote 0
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.
 
Upvote 0
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,
 
Upvote 0
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"")"
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,668
Members
448,977
Latest member
moonlight6

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
Back
Top