Code that worked in Office 2007 dosn't in 2010

MaxK38

New Member
Joined
Feb 18, 2010
Messages
37
My problem is that this code runs against the values and "C" is alwayse nothing so the other parts never have any values. Please help.

Code:
'Review ADM for exceptions
        Application.Worksheets("ADM").Activate
        With Worksheets("ADM").Range("A2:E1000")
            C = .Find("(" & DRef & ")", LookIn:=xlValues)
            If Not C Is Nothing Then
            firstAddress = C.Address
            'Test finding exceptions
            MsgBox (firstAddress)
            Do
                Set Tval = Worksheets("ADM").Range(C.Address)
                RTval = Right(Tval, Len(Tval) - InStr(1, Tval, ")"))
                Expt = Cells(1, Tval.Column).Value
                
                Select Case Expt
                    Case "SEG"
                        Col = "C"
                    Case "Customer"
                        Col = "E"
                    Case "Vendor"
                        Col = "D"
                    Case "Terminated"
                        Col = "B"
                    Case "Excessive"
                        Col = "F"
                    Case Else
                        Col = "F"
                    End Select
                    
                    'Export value to oSheet
                    oSheet.Range(Col & oSheet.Cells(oSheet.Rows.Count, Col).End(xlUp).Offset(1).Row) = RTval
                    'Autofit for printable report
                    oSheet.Range(Col & oSheet.Cells(oSheet.Rows.Count, Col).End(xlUp).Offset(-1).Row).EntireColumn.AutoFit
                    
                Set C = .FindNext(C)
                Loop While Not C Is Nothing And C.Address <> firstAddress
            End If
                
        End With
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I don't see anything in that code that wouldn't work, or would be different, in 2010.

There is one thing though - you have no worksheet reference here.
Code:
Expt = Cells(1, Tval.Column).Value
Try adding a reference to the relevant worksheet.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

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