Desperate - Need help copying cells from one sheet to another... PLEASE HELP!!

JETTLIFE

New Member
Joined
Apr 15, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Provide for the coders:

Version of the program
Microsoft Excel for Office 365 ProPlus – Excel version: 1908

What I need it to do
I need a VBA macro that will create a new sheet with all Page names, Page Numbers, and Page URLs from another sheet.

In theory it would work something like this: the vba code will find the first cell with text that contains “Site Page” select that cell and the cell next to it that starts with “Page Name”; AND find the next cell under the Site Page that contains “Page URL” select that cell and the cell next to it on the right with the actual URL. Copy the selection range and paste into a new sheet titled “FINAL URL LIST” in the next empty row.

Few key things it needs to do.

  • When first running the code, it needs to check if the sheet “Final URL List” exists, if it does, then clear it all and add Date and time stamp into A1. If does NOT exist, then create the tab, and add Date and time stamp into A1
  • Metadata tab layout changes from user to user based on there preference, so the VBA code cannot rely on find first instance, and offset copy. It needs to dynamically search for Site Page # to select and then the Page URL to select then copy and paste
  • The sheet named “Final URL List” will exist in all variations of the workbook.
  • The document is setup for SEO to create search engine listing text per webpage, and Social Media to set the OG sharing tags. We only want to grab the Site Page line that is correlated to the SEO metadata and not Open Graph stuff. So the vba will need to skip every other found row with text that contains “Site Page:”
Error messages if any
Endless loop

Sample data (before and after sample worksheets, add as attachments here)
Here is the workbook I have been working on – I have gotten the code close to working a few times, but then the loop will run away, or It will copy but not paste. Weird stuff keeps happening and I am begging for help!

If the link doesn’t work -> https://cloud.jettlifetech.com/excel-vba/MetaCheck+3.0+-+Auto+Gen+Pages+and+URLs.xlsm
VBA Code:
Sub LoopThroughUntilBlanks2()'this one is getting really close, just not pasting right
'UpdatebyExtendoffice20161222
      ' Select cell A2, *first line of data*.
      Dim xrg As Range
      Dim textToSearchFor As String
      On Error Resume Next
      
      Set xrg = Range("a2")
Worksheets("HD metadata").Activate
      xrg.Cells(2, 0).Select ' Set Do loop to stop when 3 consecutive empty cells are reached.
'      Application.ScreenUpdating = False

      Do Until IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1, 0))
         ' Insert your code here.
         
textToSearchFor = "site page:"

Cells.Find(What:=textToSearchFor, After:=ActiveCell, LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Select
        
        'Select and copy addtinoal cells to the found cell
    Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 1)).Copy
    'Selection.Copy
    
    'copy the selection to last empty row of another worksheet
    
   Worksheets("sheet2").Activate
            'find the last row of data in the worksheet, and paste below
    Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
    Worksheets("HD metadata").Activate
         ' Step down 2 rows from present location.
         ActiveCell.Offset(2, 2).Select
      Loop
      MsgBox ("empty")
      'Application.ScreenUpdating = False
      
End Sub

Here is an example of the basic output I need ->
To make it absolutely perfect -> Here is an example of how the data could be processed to really help users read through by putting the data into a table -- screenshot
Here is the VBA i have for checking if a specific worksheet exist, and if not, creates one, if it does exist, it clears and sets datea and time in A1 - this is fully working, but im not sure how to combine the VBA.
VBA Code:
Function CreateSheetIf(strSheetName As String) As BooleanDim wsTest As Worksheet
CreateSheetIf = False
Set wsTest = Nothing
On Error Resume Next
Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
On Error GoTo 0
 
If wsTest Is Nothing Then
 CreateSheetIf = True
 Worksheets.Add.Name = strSheetName
End If
End Function
Sub Test()
'Create worksheet "Bob" if it doesn't exist. Display Message box if
'sheet is created.
If CreateSheetIf("FINAL URL LIST") Then
 MsgBox ("Welcome to the workbook Bob!")
End If
End Sub
Politeness and gratitude
This is my first time posting, even though I have relied on these forms to help me forever I hope someone can actually help with this specific need. I will be in forever debt to you and the community as you will save my sanity and I will feel obligated to begin contributing to these forms if someone can pretty please help me! I would appreciate any help at all!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!


Cross posted at: Desperate - Need help copying cells from one sheet to another... PLEASE HELP!!!!
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!


Cross posted at: Desperate - Need help copying cells from one sheet to another... PLEASE HELP!!!!
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.

Her i aplogize for this, i just posted here as well because the prompt after i posted was kind of leading me that way. I will review the forum rules now, thank you for bringing to my attention.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

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