Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why am I getting this error?

Status
Not open for further replies.

Groves22

Technical User
Jan 29, 2009
102
US
This is occuring in a For Loop. The loop will look at cell W5 through AB5 one by one.

Here is what I got. I am omitting some code for space. I think I have included everything needed.

Code:
Public rYear As String, rDay As String, rMonth As String, rCount As Integer, rAgency As String, rAgentN As String

Sub Update_Report()

        Dim i As Integer, j As Integer, k As Integer, l As Integer

        For l = 23 To 28
            [b]rAgentN = FormatM.Sheets(1).Cells(5, l)[/b]

If I were to say

Code:
rAgentN = FormatM.Sheets(1).Range("rAgent")

In which rAgent is cell W5, it works. Why won't it work for .Cells (5, l), which is Cells(5,23), which is cell W5?

I get a type mismatch error.
 


Hi,

Maybe...
Code:
rAgentN = CStr(FormatM.Sheets(1).Cells(5, l).Value)

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip...

That stopped the VBA error box from popping up, but now the value for rAgentN is 'Error 2024', instead of the desired '011'
 
And this ?
rAgentN = FormatM.Sheets(1).Cells(5, l).Text

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hey PHV/Skip...

Nevermind, I'm an idiot! I had it looking at row 5, when it should have been row 7.

My original code works with 7 implace of 5.

Thanks for trying to help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top