Search header

christypraveen

New Member
Joined
Apr 11, 2020
Messages
19
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi.. I need help..i want to search header using header name in sheet 2 and select those values in down cells and copy and paste in sheet 1..but header will merged with 10 colum. Down of the header there will be 10 values in 10 colum.. Select those and paste in sheet 1.for examaple u can see in image I given 3 colum n sub header n down value.those value need be select with sub header and pasted in sheet 1. can help me get code fr this
 

Attachments

  • IMG_20200528_001925.jpg
    IMG_20200528_001925.jpg
    35.7 KB · Views: 11

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.
This might work for you. But be aware that vba does not like merged cells. However, this tested OK.


VBA Code:
Sub t()
Dim fn As Range, ary As Variant, str As String
str = InputBox("Enter the string to find.", "SEARCH ITEM")
Set fn = Range("1:1").Find(str, , xlValues)
    If Not fn Is Nothing Then
        ReDim ary(1 To 1, 1 To 10)
        ary = fn.Offset(1).Resize(, 10).Value
        Sheet1.Cells(Rows.Count, 1).End(xlUp)(2).Resize(, 10) = ary
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,684
Members
449,048
Latest member
81jamesacct

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