Copy all rows that contain certain text in a column to another sheet with button click

Wim

New Member
Joined
May 16, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I've search the forum for answers but can't find a solution I need.

I have no idea how to code VBA for this. Basically the workbook is used to work out a quote and then I would like to save the scenario used to another sheet so that I can look back to see what scenario I used the last time for the same client. Cell K3 is a dropdown list with all the clients. All text in green can be different for each client and also be different for the same client for the next month.

See first image attached.

Actual workbook contains many more rows of data. If column R contains text then if a button is clicked, copy all the rows containing text in column R to the "scenario" sheet. But the data should only be added to the last empty row on this sheet. So previous data added to this sheet(scenario) is never deleted or overwritten.
The data that should be copied is the client(K3), todays date(B3), the data in column B, E, F, G, H, cell I4, I, J, cell R4 & R of the same row containing the text in column R.

The second image attached(scenario sheet) shows an example of how the data should be transfers and saved on the "scenario" sheet.

Hope this is clear to understand.

Any help will be appreciated.

Thanks
Wim
 

Attachments

  • Main Sheet.png
    Main Sheet.png
    47.9 KB · Views: 11
  • Scenario Sheet.png
    Scenario Sheet.png
    32.4 KB · Views: 12

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Could you post a sample sheet via XL2BB tool? Helpers dont have much time to retype the data
 
Upvote 0
Sure

MAIN SHEET:
MAIN.xlsm
BCDEFGHIJKLMNOPQR
316 05 2022COFCOMEI
4TWSTR19.00R3.213de LAASTEDATUM2de LAASTEDATUMLAASTEDATUMDIESELR22.21
5Laaipunt AfstandToll%mtkm/lFormuleF14DKTARIEFKWOTEERTARIEFKWOTEERTARIEFKWOTEERAANPASSINGTarief/ton
6AFRIKASKOP200R2140341.85R374R323R343    R31029 09 2021R310R320
MAIN
Cell Formulas
RangeFormula
B3B3=TODAY()
J4J4=R4-I4
H6H6=IFERROR(SUM((C6*2/G6)*$R$4/(E6/100)/F6+D6), " ")
I6I6=IFERROR(SUM(($C6*2/$G6)*$I$4/($E6/100)/$F6+$D6), " ")
J6J6=IFERROR(SUM((($I6-$D6)+($C6*2/$G6*$J$4/$F6))+$D6), " ")
K6K6=@IF($M6="", "", LET(y,MATCH($C6,#REF!$A$7:$A$267,0),x, FILTER(#REF!$B$2:$DB$267,((#REF!$B$3:$DB$3=$L$4)*INDEX(#REF!$B$2:$DB$267,y+5,))<>0,""), IFERROR(INDEX(x, y+5,COLUMNS(x)-2),"")))
L6L6=IF(LET(y,MATCH($C6,#REF!$A$7:$A$267,0),x, FILTER(#REF!$B$2:$DB$267,((#REF!$B$3:$DB$3=$L$4)*INDEX(#REF!$B$2:$DB$267,y+5,))<>0,""), IFERROR(INDEX(x, 1,COLUMNS(x)-2),""))=$O6, "", LET(y,MATCH($C6,#REF!$A$7:$A$267,0),x, FILTER(#REF!$B$2:$DB$267,((#REF!$B$3:$DB$3=$L$4)*INDEX(#REF!$B$2:$DB$267,y+5,))<>0,""), IFERROR(INDEX(x, 1,COLUMNS(x)-2),"")))
M6M6=IF($O6="", "", LET(y,MATCH($C6,#REF!$A$7:$A$267,0),x, FILTER(#REF!$B$2:$DB$267,((#REF!$B$3:$DB$3=$L$4)*INDEX(#REF!$B$2:$DB$267,y+5,))<>0,""), IFERROR(INDEX(x, y+5,COLUMNS(x)-1),"")))
N6N6=IF(LET(y,MATCH($C6,#REF!$A$7:$A$267,0),x, FILTER(#REF!$B$2:$DB$267,((#REF!$B$3:$DB$3=$L$4)*INDEX(#REF!$B$2:$DB$267,y+5,))<>0,""), IFERROR(INDEX(x, 1,COLUMNS(x)-1),""))=$Q6, "", LET(y,MATCH($C6,#REF!$A$7:$A$267,0),x, FILTER(#REF!$B$2:$DB$267,((#REF!$B$3:$DB$3=$L$4)*INDEX(#REF!$B$2:$DB$267,y+5,))<>0,""), IFERROR(INDEX(x, 1,COLUMNS(x)-1),"")))
Cells with Data Validation
CellAllowCriteria
K3ListKLIENT, SEABOARD, UNIGRAIN, LDC, BESTER, TIGER, GRAINOVATION, BRISEN, COFCO, FLOTANK, AMEROPA, WILMAR, OLAM, GRAINVEST, AFGRI, SENWES, BELVIDERE, CARGILL


SCENARIO SHEET:
MAIN.xlsm
BCDEFGHIJKLM
2ClientDateLaaipunt %mtkm/lFormuleF14DK DieselDKDiesel PrysTARIEF
3COFCO16 05 2022AFRIKASKOP40341.85R374R323R19.00R343R22.21R320
SCENARIOS
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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