Correct/Incorporation of a needed macro into existing code that adds an automatic hyperlink. Both triggered by same selection on a dropdown

Raceman

Board Regular
Joined
Mar 11, 2010
Messages
64
Hello: I need help in completing a macro and incorporating it into some existing code that does function as designed. It's close to working but I haven't been able to get it right.

The 1st part of the code adds a hyperlink (and it works properly) see below

The 2nd part is the problem, I'm trying to trigger a copy and paste event with the same trigger as is done with the hyperlink (above), it is triggered when a selection is made in the active sheet column K and the dropdown selection of "Cable Assy" is made. I'm trying to copy Active row cell A and B and paste them in A and B on Sh2 (CABLE_MATRIX) into the next blank row. Which also happens to be the same row as what the automatic hyperlink attached to.

Note: my code that attempts to do what I am trying to do is currently set to copy only A. It doesn't fail, but it copies and pastes the dropdown info from K to cell A on the CABLE_MATRIX sheet.

HTML:
'This is option A to add hyperlink automatically. When "Cable Assy..." in column k dropdownn is selected then
'a hyperlink is automatically created which links to the next blank cell A on the Cable Matrix Worksheet.
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rws As Long, sh As Worksheet
    Set sh = Worksheets("CABLE_MATRIX")
    With sh
        Rws = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    End With
    If Target.Count = 1 And Target.Column = 11 Then
       If InStr(Target, "Cable Assy") <> 0 Then
           ActiveSheet.Hyperlinks.Add Anchor:=Target.Offset(0, 5), Address:="", SubAddress:= _
                                      "CABLE_MATRIX!A" & Rws, TextToDisplay:="CABLE_MATRIX!A" & Rws
     End If
     
    End If
    
    'This code automatically copies info from active cells A and B  to CABLE_MATRIX Sheet with same trigger as above
    '(when "Cable Assy" is selected in dropdown cell K  in Sheet "MAD_CAT -which is the active sheet)
    Dim fVal As Range
    If Not Intersect(Target, Range("K:K")) Is Nothing Then
        Set fVal = Sheets("CABLE_MATRIX").Range("A:A").Find(Range("A" & Target.Row).Value, LookIn:=xlValues)
                Target.Resize(1, 2).Copy Sheets("CABLE_MATRIX").Range("A" & fVal.Row)
   
End If

Thanks I would really appreciate your help on this
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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