Search criteria and place info from cells in another sheet of cells

Caveman1964

Board Regular
Joined
Dec 14, 2017
Messages
127
Office Version
  1. 2016
Platform
  1. Windows
Please help...I have spent hours trying to figure this out but nothing works....yes i am very ignorant about VBA and trying to learn but need this.
I need a search button as described below.
Any help will be appreciated.
Sheet 1

A
B
C
D
E
F
1
123456





2
234567





3
345678





4
456789
10/2/1810/3/18
10/5/1810/8/18
5
567890






<tbody>
</tbody>

Sheet 2 - A macro vba search button that finds criteria in A:A on sheet 1
For example, search finds job 456789 and picks up what is in row with 4 of sheet 1 (Job number)
And puts it in cells on sheet 2 like this.

A
1
10/2/18
2
10/3/18
3

4
10/5/18
5
10/8/18

<tbody>
</tbody>
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try:
Code:
Sub CopyRange()
    Application.ScreenUpdating = False
    Dim response As String, val As Range, lCol As Long
    response = InputBox("Please enter value to search.")
    If response = "" Then
        Exit Sub
    Else
        Set val = Sheets("Sheet1").Range("A:A").Find(response, LookIn:=xlValues, lookat:=xlWhole)
        If Not val Is Nothing Then
            lCol = Sheets("Sheet1").Cells(val.Row, Columns.Count).End(xlToLeft).Column
            Sheets("Sheet1").Range("B" & val.Row).Resize(1, lCol - 1).Copy
            Sheets("Sheet2").Cells(1, 1).PasteSpecial Transpose:=True
        Else
            MsgBox ("Value not found.")
        End If
    End If
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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