Write x amount of values to next available cell based on another cell

Ace71425

Board Regular
Joined
Apr 20, 2015
Messages
130
Alright I have a doozy for everybody. I have a master sheet that I copy information in from rep's tracking sheets for the work they do. I created a sheet that auto copies all of their sheets based on the file paths which I use another button to populate in row J. Everything is working swimmingly and the formatting is great but I need something done first. At the next available cell in the C column of their tracking sheets I need to input HOURS for how many hours they work based on their input of how many hours they worked on say D5. So I'm thinking a code similar to the one below that I use to open and copy their sheets except what it does is it checks D5 for the value say they work 8 hours and then it writes 8 "HOURS" texts into 8 cells in the next available cell in column C. I then want it to save their sheet with the changes and close. Please let me know if this is not making sense and i'll clarify lol. I look forward to your answers, excel gods!

Code:
Sub RunAllMacros()


    Dim wbSource As Workbook
    Dim wsDest As Worksheet
    Dim row As Integer, os As Integer
    
    Set wsDest = ThisWorkbook.Worksheets("File Copier")
    
    row = 2
    os = 0
    
    With wsDest
        Do While .Range("J" & row).Value <> ""
            Set wbSource = Workbooks.Open(wsDest.Range("J" & row).Value)
            wbSource.Worksheets(1).Range("A5:D500").Copy
            Application.DisplayAlerts = False
            wbSource.Close
            Application.DisplayAlerts = True
            If .Range("A1").Value <> "" Then os = 1
            .Range("A" & .Rows.Count).End(xlUp).Offset(os).PasteSpecial
            row = row + 1
        Loop
    End With
    
    Set wbSource = Nothing
    
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,228
Messages
6,170,875
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