Extract Data From Selected Cells and Paste into a seperate sheet

Adam_98

New Member
Joined
Sep 17, 2021
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm trying to build my spreadsheet for work and you guys have been helpful with any previous questions I've posted.

My objective is to get my data from one sheet that I would have pasted in to populate into a new sheet my clicking a Button. I've used some old code which can hopefully be altered and make this happen.
In an Ideal world I would input my data in from a website into the "Omni Look-Up" sheet. I would then want this data to filter down to the selected fields I've chosen ( In the Grid). After that's done, I would like to click a button and it would copy over the cells from the filtered data into the "Master" sheet. The final thing is when I put new data in I would like it to go in the row below on the "master sheet".
I've posted the code which has been used previously so not sure if this can be tweaked.


VBA Code:
Sub OmnipartData()
  
    Application.ScreenUpdating = False
  
        Dim rng As Range
        Dim cell As Range
        Dim rng2 As Range
        Dim cell2 As Range
      
        Set rng = Range("A2:A40")
        Set rng2 = Range("F2:F10")
      
        For Each cell In rng
      
            CurrentTitle = cell.Value
            CurrentDate = ""
          
            For Each cell2 In rng2
                CurrentTitle2 = cell2.Value
                If CurrentTitle2 = CurrentTitle Then
                    CurrentData = cell2.Offset(0, 1)
                End If
            Next cell2
          
            If CurrentData <> "" Then
                cell.Offset(0, 1).Value = CurrentData
            ElseIf CurrentData = "" Then
                MsgBox ("Error placing data for " & CurrentTitle)
            End If
      
        Next cell
      
    Application.ScreenUpdating = True
  
    MsgBox "Completed"
  
End Sub
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
When posting vba code you will get much better help if you use code tags to preserve formatting. My signature block below has more information about that. I have fixed it for you this time.
 
Upvote 0
Sorry Peter I didn't know this but I have followed the hyperlink in your signature and it was useful. I'll do this next time.
 
Upvote 0
Sorry Peter I didn't know this but I have followed the hyperlink in your signature and it was useful. I'll do this next time.
Cheers. No problem - it takes a while to find your way around all aspects of the forum. :)
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,681
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