Macro help with what if statement?

Twiglet

New Member
Joined
Apr 5, 2017
Messages
2
[TABLE="width: 602"]
<tbody>[TR]
[TD]I’m really new to recording macros, and managed to create loads of macros to get this far, but now I’m stumped.
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]I need to get rid of the <enter> that is in the same row as <esc><f9> and loop down until the end of the data 1500 rows.
[/TD]
[/TR]
[TR]
[TD]Then I need to have an account code of 30160, underneath the names, ie in column d where column a = <f4><up> again looping down to the end of the data
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]<enter> are in column G
[/TD]
[/TR]
[TR]
[TD]<esc><f9> is in column A

[TABLE="width: 471"]
<tbody>[TR]
[TD]coles[/TD]
[TD][/TD]
[TD][/TD]
[TD]SMITH[/TD]
[TD][/TD]
[TD][/TD]
[TD]<ENTER>[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]<ENTER>[/TD]
[/TR]
[TR]
[TD]<F4><UP[/TD]
[TD="align: right"]04/04/2017[/TD]
[TD]APPLES[/TD]
[TD][/TD]
[TD="align: right"]1.00 [/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]140[/TD]
[/TR]
[TR]
[TD]<F4><UP[/TD]
[TD="align: right"]13/04/2017[/TD]
[TD]APPLES[/TD]
[TD][/TD]
[TD="align: right"]1.00 [/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]140[/TD]
[/TR]
[TR]
[TD]<F4><UP[/TD]
[TD="align: right"]18/04/2017[/TD]
[TD]PEARS[/TD]
[TD][/TD]
[TD="align: right"]1.00 [/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]140[/TD]
[/TR]
[TR]
[TD]<ESC><F9>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]<ENTER>[/TD]
[/TR]
[TR]
[TD]woolworths[/TD]
[TD][/TD]
[TD][/TD]
[TD]JONES[/TD]
[TD][/TD]
[TD][/TD]
[TD]<ENTER>[/TD]
[/TR]
[TR]
[TD]<F4><UP[/TD]
[TD="align: right"]04/04/2017[/TD]
[TD="colspan: 2"]BANANAS[/TD]
[TD="align: right"]1.00 [/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]140[/TD]
[/TR]
[TR]
[TD]<F4><UP[/TD]
[TD="align: right"]06/04/2017[/TD]
[TD]APPLES[/TD]
[TD][/TD]
[TD="align: right"]1.50 [/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]120[/TD]
[/TR]
[TR]
[TD]<ESC><F9>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]<ENTER>[/TD]
[/TR]
[TR]
[TD]aldi[/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]CAMPBELL[/TD]
[TD][/TD]
[TD]<ENTER>[/TD]
[/TR]
[TR]
[TD]<F4><UP[/TD]
[TD="align: right"]18/04/2017[/TD]
[TD]APPLES[/TD]
[TD][/TD]
[TD="align: right"]1.50 [/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]140[/TD]
[/TR]
</tbody><colgroup><col><col><col span="5"></colgroup>[/TABLE]



[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Twiglet,

If this is what your raw data looks like?


Excel 2007
ABCDEFG
1colesSMITH
2
34/4/2017APPLES1.004140
413/04/2017APPLES1.004140
518/04/2017PEARS1.004140
6
7woolworthsJONES
84/4/2017BANANAS1.004140
96/4/2017APPLES1.504120
10
11aldiCAMPBELL
1218/04/2017APPLES1.504140
13
Sheet1


Then, what should the results look like?
 
Last edited:
Upvote 0
Twiglet,

1. Are these the results you are looking for?


Excel 2007
ABCDEFG
1colesSMITH
2
34/4/2017APPLES301601.004140
413/04/2017APPLES301601.004140
518/04/2017PEARS301601.004140
6
7woolworthsJONES
84/4/2017BANANAS301601.004140
96/4/2017APPLES301601.504120
10
11aldiCAMPBELL
1218/04/2017APPLES301601.504140
13
Sheet1


2. Or, are these the results you are looking for?


Excel 2007
ABCDEFG
1colesSMITH
230160
34/4/2017APPLES301601.004140
413/04/2017APPLES301601.004140
518/04/2017PEARS301601.004140
6
7woolworthsJONES
84/4/2017BANANAS301601.004140
96/4/2017APPLES301601.504120
10
11aldiCAMPBELL
1218/04/2017APPLES301601.504140
13
Sheet1


3. What is the raw data worksheet name?
 
Upvote 0

Forum statistics

Threads
1,223,920
Messages
6,175,373
Members
452,638
Latest member
Oluwabukunmi

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