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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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