Copy paste value when selecting from drop-down list

tinezi

New Member
Joined
May 17, 2022
Messages
7
Office Version
  1. 2021
Platform
  1. Windows
Hi,
I just can't figure out the VBA needed for this

When on 'Tenders' sheet and selecting for G15 "Ongoing", it should create an event that copypastes value from 'Data1' cell L6 to 'Tenders B15

When selecting "Ongoing" the code should recognize the company in question CompanyA/B/C/D in 'Tenders' and then copypaste from the value from Data1 L6/M6/N7/O6 to Tender-sheet.

In Data1 I have created a system that it generates the next available free project number for the companyA/B/C/D respectively. And always using the same cell where it will be generated.

tender-project-management.xlsm
ABCDEFG
1TENDERS
2
3
4Tender numberProject number TypeGroup companyProject namePriceSTATUS
5T603CompanyA1001SubcontractCompanyABogus project aa100 €Ongoing
6T604CompanyD4001MaincontractCompanyDBogus project bb200 €Ongoing
7T605CompanyC3001MaincontractCompanyCBogus project cc300 €Ongoing
8T606CompanyB2001MaincontractCompanyBBogus project dd200 €Ongoing
9T607CompanyA1002MaincontractCompanyABogus project ee200 €Ongoing
10T608SubcontractCompanyBBogus project ff300 €Waiting
11T609SubcontractCompanyABogus project dd300 €Waiting
12T610CompanyD4002MaincontractCompanyDBogus project ee250 €Ongoing
13T611CompanyC3002MaincontractCompanyCBogus project ff150 €Ongoing
14T612CompanyB2002MaincontractCompanyBBogus project gg200 €Ongoing
15T613MaincontractCompanyABogus project hh
16T614SubcontractCompanyCBogus project ii
17T615SubcontractCompanyABogus project jj
18T616MaincontractCompanyDBogus project kk400 €Waiting
19T617CompanyC3003MaincontractCompanyCBogus project ll250 €Ongoing
20T618MaincontractCompanyBBogus project mm100 €Waiting
21T619MaincontractCompanyABogus project nn
22T620SubcontractCompanyBBogus project oo
Tenders
Cell Formulas
RangeFormula
A6:A22A6=A5+1
Cells with Data Validation
CellAllowCriteria
C5:C404List=Menut!$C$2:$C$5
D5:D404List=Menut!$A$2:$A$6
G5:G22List=Menut!$B$2:$B$5



Data1 sheet

Cell Formulas
RangeFormula
A4:A21A4=IF(LEFT(Tenders!B5,8)="CompanyA",Tenders!B5,"")
B4:B21B4=IF(LEFT(Tenders!B5,8)="CompanyB",Tenders!B5,"")
C4:C21C4=IF(LEFT(Tenders!B5,8)="CompanyC",Tenders!B5,"")
D4:D21D4=IF(LEFT(Tenders!B5,8)="CompanyD",Tenders!B5,"")
F4:I21F4=IFERROR(INDEX(A$4:A$5002,SMALL(IF((A$4:A$5002<>""),ROW(A$4:A$5002)-ROW(A$4)+1),ROWS(A$4:A4))),"")
L4L4=INDEX($F$3:$F$5002,MATCH(TRUE,$F$3:$F$5002="",0)-1)
M4M4=INDEX($G$3:$G$5002,MATCH(TRUE,$G$3:$G$5002="",0)-1)
N4N4=INDEX($H$3:$H$5002,MATCH(TRUE,$H$3:$H5002="",0)-1)
O4O4=INDEX($I$3:$I$5002,MATCH(TRUE,$I$3:$I$5002="",0)-1)
L5:O5L5=LEFT(L4,AGGREGATE(15,6,FIND(SEQUENCE(10,,0),L4),1)-1)
L6:O6L6=L5&TEXT(SUBSTITUTE(L4,L5,"")+1,REPT(0,LEN(L4)-LEN(L5)))
Press CTRL+SHIFT+ENTER to enter array formulas.



Help please!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Answering to myself. It was easier solution than I first thought...

Even added an automatic datestamp on the right side

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim RelevantArea As Range
    Set RelevantArea = Intersect(Target, Range("G:G"))
    If Not RelevantArea Is Nothing Then
        If Target.Value = "Ongoing" Then
            Application.EnableEvents = False
            Target.Offset(0, 1).Value = Format(Now, "dd.mm.yyyy")
            Application.EnableEvents = True
        End If
             If Range("D" & Target.Row).Value = "CompanyA" Then
                 Application.EnableEvents = False
                 Target.Offset(0, -5).Value = Worksheets("Data1").Range("L6").Value
                 Application.EnableEvents = True
              ElseIf Range("D" & Target.Row).Value = "CompanyB" Then
                 Application.EnableEvents = False
                 Target.Offset(0, -5).Value = Worksheets("Data1").Range("M6").Value
                 Application.EnableEvents = True
              ElseIf Range("D" & Target.Row).Value = "CompanyC" Then
                 Application.EnableEvents = False
                 Target.Offset(0, -5).Value = Worksheets("Data1").Range("N6").Value
                 Application.EnableEvents = True
              ElseIf Range("D" & Target.Row).Value = "CompanyD" Then
                 Application.EnableEvents = False
                 Target.Offset(0, -5).Value = Worksheets("Data1").Range("O6").Value
                 Application.EnableEvents = True
                    End If
    End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,839
Messages
6,121,892
Members
449,058
Latest member
Guy Boot

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