Looping worksheet in three directions

twckfa16

New Member
Joined
Dec 17, 2012
Messages
31
Hello - Can anyone help with this one?
I have two files - data.xlsm and sched.xls.
The objective:
1) In data.xlsm, after hitting "GO", loop through column A. If you find a string that starts with "GB",
Do this:
2) Convert date which is next column over in data.xlsm to dd-mmm
3) Open sched.xls
4) Loop through first row until you find date (dd-mmm)
5) When you find date, loop through that column unitl string "POC" is found
6) When you find "POC", go to column A where you will find a name
7) Take the name and put it in data.xlsm.

Here is the code so far:
Code:
Dim dtLast As Date, strLMFile As String
Dim sched_dir As String, sched As String, sched_file As String
Dim LRow As Long, n As Long
Dim rCell As Range
Dim Rng As Range
Dim Rngbw As Range
Dim cel, cel_b As Range
Dim a, b, l As String
Dim cRow As Long, LastRow As Long
Dim i, j As Integer
Dim counter_1 As Integer
strFolder = "H:\"
strFile = dir("H:\sched.xls")
strLMFile = strFolder & strFile
Workbooks.Open (strLMFile)
Workbooks("data.xlsm").Activate
Worksheets("Sheet1").Select
With ThisWorkbook.Sheets("Sheet1")
Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
End With
For Each cel In Rng
    If InStr(cel.Value, "GB") Then
       a = cel.Offset(0, 1)
       b = Format(a, ("dd-mmm"))
       
       Workbooks("sched.xls").Activate
       
       For Each cel_b In Range("A1:HZ1")
           If cel_b.Value = b Then
              
End Sub
If something can point me in the right direction, I would really appreciate it.

Thanks
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I haven't looked closely at your code, but inside a With ... End With construct you need to qualify the properties with a dot:

Rich (BB code):
Set Rng = .Range(.Range("A1"), .Range("A" & .Rows.Count).End(xlUp))

If you don't the ActiveSheet will be used.
 
Upvote 0
I'm still struggling a little...basically need to search in three directions:

1) Start with A1 and search the first row (x) until correct date is found
2) Search down (y) until string "POC" is found
3) Then go back (-x) until you reach first column and you find the name
 
Upvote 0

Forum statistics

Threads
1,203,171
Messages
6,053,871
Members
444,691
Latest member
Breizze1313

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