orangebloss
Board Regular
- Joined
- Jun 5, 2013
- Messages
- 51
- Office Version
- 365
- Platform
- Windows
Hi
I have a project list that I need to cycle through and copy a project name into another sheet, run a subroutine, then return to the original list on the next row down and continue.
1.Go to first cell of project list
2.If the value in the first cell of the row is Yes then paste the value into the Rough Cut worksheet in cell V4
3.Run the UpdateSandbox macro which copies data from the Rough Cut spreadsheet to the Sandbox Spreadsheet
4.Return to the Project List, move one cell down and repeat
5.If the value of the first cell of the row in No then go to the next row and start from 2 again
The subroutine works, but I can't get it to go to the next line to check it - any thoughts or ideas?
I have a project list that I need to cycle through and copy a project name into another sheet, run a subroutine, then return to the original list on the next row down and continue.
1.Go to first cell of project list
2.If the value in the first cell of the row is Yes then paste the value into the Rough Cut worksheet in cell V4
3.Run the UpdateSandbox macro which copies data from the Rough Cut spreadsheet to the Sandbox Spreadsheet
4.Return to the Project List, move one cell down and repeat
5.If the value of the first cell of the row in No then go to the next row and start from 2 again
The subroutine works, but I can't get it to go to the next line to check it - any thoughts or ideas?
VBA Code:
Sub Cyclethrough()
Dim x As Integer
Dim RoughCut As Worksheet
Dim ProjectList As Worksheet
Set RoughCut = Worksheets("Rough Cut")
Set ProjectList = Worksheets("Project Data (G)")
' Set numrows = number of rows of data.
NumRows = ProjectList.Range("A4", Range("A4").End(xlDown)).Rows.Count
' Select cell a1.
Range("A4").Select
' Establish "For" loop to loop "numrows" number of times.
For x = 1 To NumRows
If ActiveCell.Value = "Yes" Then
'If the value in the first cell of the row is Yes then paste the value into the Rough Cut worksheet in cell V4
Application.ScreenUpdating = False
RoughCut.Range("V4").Value = ActiveCell.Offset(0, 1).Value
Call UpdateSandbox
ActiveCell.Offset(1, 0).Select
End If
Next
End Sub