Need help with VBA code

DarkSmile

Board Regular
Joined
Feb 22, 2021
Messages
90
Office Version
  1. 365
Platform
  1. Windows
Hi,

I need some help with VBA code, I tried it myself but it's not working.

VBA Code:
Sub ACS002()
  If Sheets("List").Range("C17") = True Then
  Sheets("ACS-002").Range("A2:B32").Copy Destination:=Sheets("Data").Range("A11")
End Sub

So i have a sheet with a dropdown list where you can choose the norms, I have a list with formulas that looks if the specific norm has been chosen and if so returns TRUE.
What I'm trying to do with the VBA now is look if in specific cell it says TRUE, if so go to specified sheet and copy specific range and paste it in sheet Data starting at range A11.

VBA should be changed a bit so it says; Start a A11 , but for the other once (because I will copy/paste all the norms) paste them underneath the previous one (but skip one row).

Result:

Excel aanduiden welke normen klant heeft.xlsm
AB
1Naam klant:
2Normen:
3
4Output normenACS-002 Ind Lait, ACS-005 glaces-ijs, BVI/MPT Vleesverwerker,
5
6
7
8
9
10
11ACS-002 Ind Lait
12
13Klein bedrijf?Duid aan
14Ja
15Nee
16
17Dierenvoeders?Duid aan
18Ja
19Nee
20
21Aantal producttypes?Duid aan
221
232
243
254 of meer
26
27Producttypes?Duid aan
28UHT-consumptiemelkdranken en UHT- room
29Gesteriliseerde consumptiemelkdranken en room
30Gepasteuriseerde consumptiemelkdranken en room
31Gefermenteerde melk
32Thermisch behandelde gefermenteerde melk
33Verse kaas
34Harde kaas op basis van gepasteuriseerde melk
35Mozzarella op basis van gepasteuriseerde melk
36Zachte kaas op basis van gepasteuriseerde melk
37Zure boter op basis van gepasteuriseerde melk, verse zure karnemelk, thermisch behandelde zure karnemelk
38Melkpoeder
39Neutrale desserts
40Rauwmelkse kazen
41Zure boter op basis van rauwe melk en verse zure karnemelk
42
43ACS-005 glaces-ijs
44
45Type Bedrijf?Vul in
46Valt het bedrijf onder versoepeling MB van 24/10/05?
47Nevenstromen naar de diervoederindustrie?:
Data



Excel aanduiden welke normen klant heeft.xlsm
ABC
1NormenTRUE
2DistributionACS-003 Déb Vian#VALUE!
3ACS-007 Retail#VALUE!
4ACS-023 Horeca#VALUE!
5ACS-025 Collectiv#VALUE!
6ACS-026 boul distri#VALUE!
7ACS-041 Creche#VALUE!
8ACS-044 BtoC#VALUE!
9FeedACS-001#VALUE!
10ACS-010 Distribution#VALUE!
11ACS-010 Production#VALUE!
12ACS-038 Handel Agro#VALUE!
13Cahier végétal (BFA)#VALUE!
14FCA#VALUE!
15module I-01 Ovocom#VALUE!
16VLOG#VALUE!
17FoodACS-002 Ind LaitTRUE
18ACS-004 Brasseries#VALUE!
19ACS-005 glaces-ijsTRUE
20ACS-006#VALUE!
21ACS-009 Tran/col Lait#VALUE!
22ACS-014 Fr et Lég#VALUE!
23ACS-017#VALUE!
24ACS-018#VALUE!
25ACS-019 Fenavian#VALUE!
26ACS-020 Meuneries#VALUE!
27ACS-022 Choprabisco#VALUE!
28ACS-024#VALUE!
29ACS-026 boul transfo#VALUE!
30ACS-027#VALUE!
31ACS-029#VALUE!
32ACS-032#VALUE!
33ACS-039#VALUE!
34Belplume Slachthuis#VALUE!
35Belplume Transport#VALUE!
36BePork Slachthuis#VALUE!
37BePork Uitsnijderij#VALUE!
38BePork Vleesverwerker#VALUE!
39BePork welfare#VALUE!
40BVI/MPT Slachthuis & Uitsnijderij#VALUE!
41BVI/MPT VleesverwerkerTRUE
42Colruyt#VALUE!
43Export - China#VALUE!
44Export Zuid-Korea Koelhuis#VALUE!
45Export Zuid-Korea Slachthuis#VALUE!
46Export Zuid-Korea Uitsnijderij#VALUE!
47Export Zuid-Korea Verwerking#VALUE!
48Febev + Groothandel#VALUE!
49Febev + Slachthuis voor runderen#VALUE!
50Febev + Slachthuis voor varkens#VALUE!
51Febev + Uitsnijderij voor runderen#VALUE!
52Febev + Uitsnijderij voor varkens#VALUE!
53GRMS#VALUE!
54SPECIFIC STANDARD#VALUE!
55ISACertAOECS Module for Gluten Free FoodsN/A
56ASDA-moduleN/A
57BLKN/A
58BRC Agents & Brokers#VALUE!
59BRC Packaging#VALUE!
60BRC S&D#VALUE!
61BRC v9#VALUE!
62FSMA Module Preventive Controls PreparednessN/A
63FSSC 22000 v5#VALUE!
64GFCPN/A
65Head OfficeN/A
66IFS Broker#VALUE!
67IFS Cash & Carry v2#VALUE!
68IFS Global Markets Food#VALUE!
69IFS L#VALUE!
70IFS v7#VALUE!
71IFS Wholesale v2#VALUE!
72Meat Supply ChainN/A
73Whole Sale-moduleN/A
74Suppliers FOODAldi AustraliëN/A
75Barry CallebautN/A
76CarrefourN/A
77Delhaize - PIAN/A
78LidlN/A
79Lidl - Animal welfareN/A
80PuratosN/A
81Taste & Welfare audits - Belgian Porc GroupN/A
List
Cell Formulas
RangeFormula
C2:C54,C66:C71,C63,C58:C61C2=LOOKUP(1000,SEARCH(B2,Data!$B$4),List!$C$1)
Named Ranges
NameRefers ToCells
Output_Normen=Data!$B$4C66:C71, C58:C61, C2:C54, C63
 
Sorry for spamming; but resolved:

Code:
Sub Range_End_Method()
'Finds the last non-blank cell in a single row or column

Dim lRow As Long
Dim lCol As Long
    
    'Find the last non-blank cell in column A(1)
    lRow = Cells(Rows.Count, 1).End(xlUp).Row
    
    'Find the last non-blank cell in row 1
    lCol = Cells(1, Columns.Count).End(xlToLeft).Column
    
    If Sheets("List").Range("C19") = True Then
        Sheets("ACS-005").Range("A2:B6").Copy Destination:=Sheets("Data").Range("A" & lRow + 2)
    End If
End Sub
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
excellent - its so much more satisfying when you fix it yourself, and apologies for not replying, but only just got back to computer, All the best.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
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