gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
Can I have a vba event that does the following: Copies the values in B:U, of the same…
- User
Can I have a vba event that does the following: Copies the values in B:U, of the same row of the selected cell in column A to AA:AT
- Assistant
Yes, you can use a VBA event to achieve this task. You can use the "SelectionChange" event in the Sheet module to detect changes in the selected cell. Here's an example code that copies the values from columns B:U to AA:AT of the same row when the selection changes in column A:
vbaPrivate Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then ' Check if selection change is in column A Dim selectedRow As Long selectedRow = Target.Row ' Copy values from B:U to AA:AT of the same row Range("B" & selectedRow & ":U" & selectedRow).Copy Destination:=Range("AA" & selectedRow & ":AT" & selectedRow) End If End SubTo add this code, you need to follow these steps:
- Right-click on the sheet name in the Excel workbook.