Macro to copy from one sheet to another but with Values

KGards07

New Member
Joined
Aug 30, 2016
Messages
19
Hi,

I have an excel spread sheet with a drop down function in Sheet1 cell A2.

In Sheet 2 along Row 1 I have titles of systems running across the page. Under each title there are a number of names beneath each.

The drop down in cell A2 in Sheet1 corresponds to the titles in Sheet 2.

Essentially what I would like is whatever I select in the dropdown in Sheet 1 the names beneath that specific title in Sheet 2 would show in Sheet 1 in Cell A3 downwards. However when the names appear in Sheet 1 I need them to be in a Paste Value format - basically I don't want formulas in the cells in Sheet 1. I believe the only way to do this is a Macro but I am unsure.

The formula I am currently using in cell A3 downwards is:
=INDEX(Sheet2!$B2:DJ2,MATCH($A$2,Sheet2!$B$1:$D$1))
However this of course is a formula and is not Paste Values which is what I need.

Any help would be greatly appreciated. Thank you in advance.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this:

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet 1 tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 6/26/18 5:55 AM EDT
If Not Intersect(Target, Range("A2")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim ans As String
ans = Target.Value
Dim SearchString As String
SearchString = ans
Dim SearchRange As Range
Dim Lastrow As Long
Dim Lastrowa As Long
Dim Lastcolumn As Long
Lastrowa = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
Lastcolumn = Sheets(2).Cells(1, Columns.Count).End(xlToLeft).Column
Sheets(1).Cells(3, 1).Resize(Lastrowa).ClearContents
Set SearchRange = Sheets(2).Cells(1, 1).Resize(, Lastcolumn).Find(SearchString, LookIn:=xlValues, lookat:=xlWhole)
If SearchRange Is Nothing Then MsgBox ans & " Not found": Exit Sub
cc = SearchRange.Column
Lastrow = Sheets(2).Cells(Rows.Count, cc).End(xlUp).Row
Sheets(2).Cells(1, cc).Resize(Lastrow).Copy: Sheets(1).Range("A3").PasteSpecial xlValues
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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