Adding copy-paste into loop VBA formula

dangorka

New Member
Joined
Feb 23, 2018
Messages
11
Hi everyone

I have a quite simple Excel sheet with two tabs in it (Sheet1 and Sheet2)

Sheet 2 contains numbers in row Q and hyperlinks in column T
Basically any time when there is a number "1" in row Q, macro should copy paste hyperlink from reflective row to A4 in Sheet1, call few macros and then move back to Sheet2 and proceeds to another row with number "1" in row Q

So far I came up with this but I am not sure how can I add copy-pasting from one sheet to another into loop

Code:
Sub ScrapingAllTransfermarkt()

    Const START_ROW As Integer = 1
    
    For I = START_ROW To Cells(Rows.Count, 1).End(xlUp).Row
    
    If Cells(I, 17) = 1 Then
    
    Call transfermarkthome
    Call storeDataTransfermarktHome
    Call TransfermarktHomeClean


    End If
    Sheets("Sheet2").Select
    Next I
    
    End If
    Next I
    
End Sub

Will be grateful for any help!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Doing what you want should not be a problem. Just one question for clarification: Your current macro runs 3 other macros for every row in column Q. So if you have data in column Q down to row 100 and 50 of those rows have value of 1, the 3 macros will be run 50 times. Is this what you want to do. If not, can you post the other 3 macros and explain in detail what you are trying to do.
 
Upvote 0
Hi mumps!

Thanks for the response. Yes, that's exactly what I want, to run those 3 macros 50 times if 50 rows have value of 1! (can take some time to run everything but for the purpose of this I will be using virtual machine anyway)
 
Upvote 0
@dangorka
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Try:
Code:
Sub ScrapingAllTransfermarkt()
    Application.ScreenUpdating = False
    Dim LastRow As Long, rng As Range, desWS As Worksheet, x As Long: x = 4
    Set desWS = Sheets("Sheet1")
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For Each rng In Range("Q1:Q" & LastRow)
        If rng = 1 Then
            desWS.Range("A" & x) = rng.Offset(0, 3)
            x = x + 1
            Call transfermarkthome
            Call storeDataTransfermarktHome
            Call TransfermarktHomeClean
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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