Looping down a column and then go to the next colum and loop down it.

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have code that someone else wrote that I need to modify. It works really well but it runs the code and gathers the data down one column when we need the data from multiple columns. The user has go in and select the next row and run the code each time (over and over for 43 columns). This is also creating a separate tab, with the retrieved data, each time. We dont need separate tabs for each - all the data on one tab is the goal.

Here is the Code: BcurrentCol = StartSheet.Cells(11,1) is identifying which row the user selected. There is a Form the user uses to select the column - that selection gets placed in the (11,1).
We really don't need the user to select a column. We just need it to run through each column (L:BB)
In a perfect world it would skip rows (S:V) but that's easy enough to manually delete from the compiled info.

Code:
Sub CreateProPricer()
'Sheets("Resources(Spread Or Load)").Visible = True
 '
    Dim AspecRow
    Dim BcurrentCol
    Dim CtaskCol
    Dim DstartRow

    AspecRow = 4
    CtaskCol = 5
    DstartRow = 9
    
    Dim valueSheet As Worksheet
    Dim ProPSheet As Worksheet
    Dim StartSheet As Worksheet
    
    
    Set ValuesSheet = ThisWorkbook.Sheets("Values")
    Set StartSheet = ThisWorkbook.Sheets("Variables")
    Set ProPSheet = ThisWorkbook.Sheets("Resources (Spread or Load)")
    
    
    BcurrentCol = StartSheet.Cells(11, 1).value
    
    Dim j
    j = DstartRow
                Sheets("Resources (Spread or Load)").Range("A3").Select
    Do While j <= ValuesSheet.Rows.Count
        If hoursGood(j, BcurrentCol) Then
           
     
            Set ProPSheet = ThisWorkbook.Sheets("Resources (Spread or Load)")

            '
            'WBS
            ActiveCell.value = ValuesSheet.Cells(j, 1).value
            'CAT
            ActiveCell.Offset(0, 2).value = ValuesSheet.Cells(AspecRow, BcurrentCol).value
            'Spread Code
            ActiveCell.Offset(0, 6).value = ValuesSheet.Cells(j, 9).value
            'Value
            ActiveCell.Offset(0, 7).value = ValuesSheet.Cells(j, BcurrentCol).value
            'Start
            ActiveCell.Offset(0, 8).value = ValuesSheet.Cells(j, 10).value
            'End
            ActiveCell.Offset(0, 9).value = ValuesSheet.Cells(j, 11).value
            ActiveCell.Offset(1, 0).Activate
            
            
            Application.DisplayAlerts = True
        End If
        
        j = j + 1
    Loop

            Move_PP_Tab
    
End Sub
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,275
Messages
6,171,127
Members
452,381
Latest member
Nova88

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