madhuchelliah
Board Regular
- Joined
- Nov 22, 2017
- Messages
- 226
- Office Version
- 2019
- Platform
- Windows
Hello Guys, I have two scenarios to workout. Both are almost similar only small differences. I am using simple find and replace for this, but now i am having new issues. Please go through the following scenarios.
Scenario 1
The macro should read the cell C3 and delete that value in the last used row of C column. The last used row is always a string. Here i am using normal find and replace macros but now the problem is sometimes the string has the value of C3 multiple times. But i want to delete the last instance(Bold Value) or 1st instance from right side of the value in the string. See the example below.
[TABLE="class: grid, width: 200, align: left"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]XXX[/TD]
[TD="align: center"]XXX[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]25B[/TD]
[TD="align: center"]25B[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]ZZZ[/TD]
[TD="align: center"]ZZZ[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]25B 250 25B 25 25B[/TD]
[TD="align: center"]25B 250 25B 25[/TD]
[/TR]
</tbody>[/TABLE]
Scenario 2
This one is pretty similar to the 1st one. The macro should read the contents before the minus symbol in the string of cell C3 and remove that content from 1st instance of the string in last used row of C column. See the example below.
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]XXX[/TD]
[TD="align: center"]XXX[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]25 B -1[/TD]
[TD="align: center"]25 B -1[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]ZZZ[/TD]
[TD="align: center"]ZZZ[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]AAA[/TD]
[TD="align: center"]AAA[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]25 B 100 25 B 105 110[/TD]
[TD="align: center"]100 25 B 105 110[/TD]
[/TR]
</tbody>[/TABLE]
I need 2 different macros for the two scenarios. I am not an expert to solve this. Please anyone heads up. Thank you.
Scenario 1
The macro should read the cell C3 and delete that value in the last used row of C column. The last used row is always a string. Here i am using normal find and replace macros but now the problem is sometimes the string has the value of C3 multiple times. But i want to delete the last instance(Bold Value) or 1st instance from right side of the value in the string. See the example below.
[TABLE="class: grid, width: 200, align: left"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]XXX[/TD]
[TD="align: center"]XXX[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]25B[/TD]
[TD="align: center"]25B[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]ZZZ[/TD]
[TD="align: center"]ZZZ[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]25B 250 25B 25 25B[/TD]
[TD="align: center"]25B 250 25B 25[/TD]
[/TR]
</tbody>[/TABLE]
Scenario 2
This one is pretty similar to the 1st one. The macro should read the contents before the minus symbol in the string of cell C3 and remove that content from 1st instance of the string in last used row of C column. See the example below.
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]XXX[/TD]
[TD="align: center"]XXX[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]25 B -1[/TD]
[TD="align: center"]25 B -1[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]YYY[/TD]
[TD="align: center"]YYY[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]ZZZ[/TD]
[TD="align: center"]ZZZ[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]AAA[/TD]
[TD="align: center"]AAA[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]25 B 100 25 B 105 110[/TD]
[TD="align: center"]100 25 B 105 110[/TD]
[/TR]
</tbody>[/TABLE]
I need 2 different macros for the two scenarios. I am not an expert to solve this. Please anyone heads up. Thank you.
Last edited: