Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Code ran, now it doesn't

In an earlier post, I posted this code, which didnt' run.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim iOrigCityNo, iEndRow As Integer


strOrig = ActiveSheet.Range("A2")
iOrigCityNo = Left(strOrig, 2)
iEndRow = ActiveSheet.Range.Cells(Rows.C*ount, "B").End(xlUp).Row
Set rTOCtyLst = Range(.Cells(1, 1), .Cells(1, iEndRow))


I was getting an error on the Set line.
I was also told not to use integer variable type anymore, so I changed
it to long.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim lOrigCityNo, lEndRow As Long

strOrig = ActiveSheet.Range("A2")
lOrigCityNo = Left(strOrig, 2)
lEndRow = ActiveSheet.Range.Cells(Rows.Count, "B").End(xlUp).Row

Now I'm getting a "wrong number of assignments or invalid property
assignment" error on the lEndRow= line! The only thing thats changed is
the variable type, and I was told that I didn't need to use integer any
more, just to use long. I tried changing them back to integer, but it
still gives me the error! Can anyone explain to me why code that ran
fine a week ago doesn't run at all today? Ozone layer depletion maybe?
I haven't changed the location of the code or the sheet it's supposed
to execute on.
Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Code ran, now it doesn't

You cna either use range of cells but not both. In your case you want Cells

Change
lEndRow = ActiveSheet.Range.Cells(Rows.Count, "B").End(xlUp).Row
To
lEndRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
--
HTH...

Jim Thomlinson


"davegb" wrote:

In an earlier post, I posted this code, which didnt' run.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim iOrigCityNo, iEndRow As Integer


strOrig = ActiveSheet.Range("A2")
iOrigCityNo = Left(strOrig, 2)
iEndRow = ActiveSheet.Range.Cells(Rows.CĀ*ount, "B").End(xlUp).Row
Set rTOCtyLst = Range(.Cells(1, 1), .Cells(1, iEndRow))


I was getting an error on the Set line.
I was also told not to use integer variable type anymore, so I changed
it to long.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim lOrigCityNo, lEndRow As Long

strOrig = ActiveSheet.Range("A2")
lOrigCityNo = Left(strOrig, 2)
lEndRow = ActiveSheet.Range.Cells(Rows.Count, "B").End(xlUp).Row

Now I'm getting a "wrong number of assignments or invalid property
assignment" error on the lEndRow= line! The only thing thats changed is
the variable type, and I was told that I didn't need to use integer any
more, just to use long. I tried changing them back to integer, but it
still gives me the error! Can anyone explain to me why code that ran
fine a week ago doesn't run at all today? Ozone layer depletion maybe?
I haven't changed the location of the code or the sheet it's supposed
to execute on.
Any ideas?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Code ran, now it doesn't

Looking at your variable declarations you should probably give Chips site a
quick look. Some of your declarations are not working out as you intend them
I suspect...

http://www.cpearson.com/excel/variables.htm

Dim X, Y, Z As Single

is not the same as declaration

Dim X As Single, Y As Single, Z As Single

It is the same as

Dim X As Variant, Y As Variant, Z As Single

or, more explicitly, as

Dim X As Variant
Dim Y As Variant
Dim Z As Single


--
HTH...

Jim Thomlinson


"davegb" wrote:

In an earlier post, I posted this code, which didnt' run.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim iOrigCityNo, iEndRow As Integer


strOrig = ActiveSheet.Range("A2")
iOrigCityNo = Left(strOrig, 2)
iEndRow = ActiveSheet.Range.Cells(Rows.CĀ*ount, "B").End(xlUp).Row
Set rTOCtyLst = Range(.Cells(1, 1), .Cells(1, iEndRow))


I was getting an error on the Set line.
I was also told not to use integer variable type anymore, so I changed
it to long.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim lOrigCityNo, lEndRow As Long

strOrig = ActiveSheet.Range("A2")
lOrigCityNo = Left(strOrig, 2)
lEndRow = ActiveSheet.Range.Cells(Rows.Count, "B").End(xlUp).Row

Now I'm getting a "wrong number of assignments or invalid property
assignment" error on the lEndRow= line! The only thing thats changed is
the variable type, and I was told that I didn't need to use integer any
more, just to use long. I tried changing them back to integer, but it
still gives me the error! Can anyone explain to me why code that ran
fine a week ago doesn't run at all today? Ozone layer depletion maybe?
I haven't changed the location of the code or the sheet it's supposed
to execute on.
Any ideas?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Code ran, now it doesn't

FYI; when you;

Dim iOrigCityNo, iEndRow As Integer

iOrigCityNo ends up dimensioned as Variant. If you want it as integer then
do something like;

Dim iOrigCityNo As Integer, iEndRow As Integer

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"davegb" wrote:
In an earlier post, I posted this code, which didnt' run.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim iOrigCityNo, iEndRow As Integer


strOrig = ActiveSheet.Range("A2")
iOrigCityNo = Left(strOrig, 2)
iEndRow = ActiveSheet.Range.Cells(Rows.C*ount, "B").End(xlUp).Row
Set rTOCtyLst = Range(.Cells(1, 1), .Cells(1, iEndRow))


I was getting an error on the Set line.
I was also told not to use integer variable type anymore, so I changed
it to long.

Sub CtyMatch()
Dim strOrig, strOutcomes As String
Dim rCell, rTOCtyLst As Range
Dim lOrigCityNo, lEndRow As Long

strOrig = ActiveSheet.Range("A2")
lOrigCityNo = Left(strOrig, 2)
lEndRow = ActiveSheet.Range.Cells(Rows.Count, "B").End(xlUp).Row

Now I'm getting a "wrong number of assignments or invalid property
assignment" error on the lEndRow= line! The only thing thats changed is
the variable type, and I was told that I didn't need to use integer any
more, just to use long. I tried changing them back to integer, but it
still gives me the error! Can anyone explain to me why code that ran
fine a week ago doesn't run at all today? Ozone layer depletion maybe?
I haven't changed the location of the code or the sheet it's supposed
to execute on.
Any ideas?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Create a newworksheet with VBA code and put VBA code in the new worksheet module ceshelman Excel Programming 4 June 15th 05 04:37 PM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"