Forum Discussion

tusharkaushik's avatar
tusharkaushik
Copper Contributor
Feb 23, 2021
Solved

Two diferent data in two different columns but one selection

Hello,

 

What I want is basically whenever i select D2 the same data will be shown in M3. When i go to D3 the same will be shown in M3.

 

Simultaneously When the data of D2 is getting copied to M3 automatically data for E2 as well go to M4.

I have this code

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.CountLarge = 1 Then
If Not Intersect(Target, Range("D2:D43")) Is Nothing Then
Range("M3").Value = Target.Value
ElseIf Not Intersect(Target, Range("E2:E43")) Is Nothing Then
Range("N3").Value = Target.Value
End If
End If
End Sub

 

I want this selection of two columns at once and data to be displayed in another cells to be working in this code.

 

TIA.

 

 

  • tusharkaushik 

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Selection.CountLarge = 1 Then
            If Not Intersect(Target, Range("D2:D43")) Is Nothing Then
                Range("M3").Value = Target.Value
                Range("M4").Value = Target.Offset(0, 1).Value
            End If
        End If
    End Sub

2 Replies

  • tusharkaushik 

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Selection.CountLarge = 1 Then
            If Not Intersect(Target, Range("D2:D43")) Is Nothing Then
                Range("M3").Value = Target.Value
                Range("M4").Value = Target.Offset(0, 1).Value
            End If
        End If
    End Sub

Resources