VBA loop that finds a text string, delete a range and setup a clean dataset

MRDecarte

New Member
Joined
May 24, 2014
Messages
20
Hello everyone,

I am not familiar with VBA but I look for a code that can help me to set up a report.
Basically, the code should find the word "Conf" and delete the range including the row containing the text string and 6 rows below etc..in a loop

Range("A2").Select
Cells.Find(What:="conf", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Rows("59:65").Select
Selection.Delete Shift:=xlUp

Then because I copy the data from a pdf I have some numbers or text in column A that should be cut and pasted in the last column of the above line. Likewise some numbers or text different from 2018 in Column A & B that should be cut and pasted in the last column above the line. So every time the expression i a line is different from "2018" than the number and text string should be pasted in the last column above.
[TABLE="width: 128"]
<tbody>[TR]
[TD="width: 64"]A[/TD]
[TD="width: 64"] B [/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 192"]
<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64, align: right"]2018[/TD]
[TD="width: 64, align: right"]1[/TD]
[TD="width: 64, align: right"]90712[/TD]
[/TR]
[TR]
[TD="align: right"]2018[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]90712[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 192"]
<tbody>[TR]
[TD="width: 64, align: right"][TABLE="width: 96"]
<tbody>[TR]
[TD="width: 64, align: right"]10006723 [/TD]
[TD="width: 64, align: right"]15392.64[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD="width: 64, align: right"]

[/TD]
[TD="width: 64"][/TD]
[/TR]
</tbody>[/TABLE]
I hope it is clear enough and thank you for the help much appreciated,

best regards
MRDecarte
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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