ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type mismatch error - New to VB, please help (https://www.excelbanter.com/excel-programming/414108-type-mismatch-error-new-vbulletin-please-help.html)

Erin Simons

Type mismatch error - New to VB, please help
 
My code is as follows. Please note that I can't get it to run past the first
line so I wouldn't be surprised if it is all be wrong!!

Sub Button2_Click()

Worksheets("Minutes").Activate
For Counter = 0 To UBound(Action1)
If Actions1.Text Then
Actions1.Copy
End If

Next Counter
End Sub

I get a "type mismatch" error on the line:
For Counter = 0 To UBound(Action1)
and i'm unsure what is wrong with it. Action1 is the name I have given to
my range (I just selected the range and named it). What am I doing wrong??

Thanks in Advance...

Chip Pearson

Type mismatch error - New to VB, please help
 
What is "Action1"? For UBound to work, it needs to be an array, but for Text
and Copy, it needs to be a range (I assume).


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Erin Simons" <Erin wrote in message
...
My code is as follows. Please note that I can't get it to run past the
first
line so I wouldn't be surprised if it is all be wrong!!

Sub Button2_Click()

Worksheets("Minutes").Activate
For Counter = 0 To UBound(Action1)
If Actions1.Text Then
Actions1.Copy
End If

Next Counter
End Sub

I get a "type mismatch" error on the line:
For Counter = 0 To UBound(Action1)
and i'm unsure what is wrong with it. Action1 is the name I have given to
my range (I just selected the range and named it). What am I doing
wrong??

Thanks in Advance...



Erin Simons[_2_]

Type mismatch error - New to VB, please help
 
Thanks Chip!! I'm very much a novice but your advice helped. A friend
suggested I use UBound, but I'm just using a For Each loop now, much better.

Thanks
E

"Chip Pearson" wrote:

What is "Action1"? For UBound to work, it needs to be an array, but for Text
and Copy, it needs to be a range (I assume).


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Erin Simons" <Erin wrote in message
...
My code is as follows. Please note that I can't get it to run past the
first
line so I wouldn't be surprised if it is all be wrong!!

Sub Button2_Click()

Worksheets("Minutes").Activate
For Counter = 0 To UBound(Action1)
If Actions1.Text Then
Actions1.Copy
End If

Next Counter
End Sub

I get a "type mismatch" error on the line:
For Counter = 0 To UBound(Action1)
and i'm unsure what is wrong with it. Action1 is the name I have given to
my range (I just selected the range and named it). What am I doing
wrong??

Thanks in Advance...




All times are GMT +1. The time now is 11:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com