ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type Mismatch Error in Excel VB on RowIndex (https://www.excelbanter.com/excel-programming/406283-type-mismatch-error-excel-vbulletin-rowindex.html)

Rob Fenwick

Type Mismatch Error in Excel VB on RowIndex
 
I get an error on the last line of the below snipit
Type Mismatch. I'm doing a for loop and want to
use the variables StartRow and Endrow

Any help would be greatly appreciated.
Thanks in Advance

--------
Dim StartRow As Integer
Dim EndRow As Integer

StartRow = 1
EndRow = StartRow + 3

Sheets("Master").Select
Rows("1:4").Select 'STATIC version of what I want
Rows("StartRow:EndRow").Select ' Dynamic vers of it



*** Sent via Developersdex http://www.developersdex.com ***

Mike H

Type Mismatch Error in Excel VB on RowIndex
 
Try this

Rows(StartRow & ":" & EndRow).Select ' Dynamic vers of it

Because the variables where in quotes they were inyerpreted as text

Mike

"Rob Fenwick" wrote:

I get an error on the last line of the below snipit
Type Mismatch. I'm doing a for loop and want to
use the variables StartRow and Endrow

Any help would be greatly appreciated.
Thanks in Advance

--------
Dim StartRow As Integer
Dim EndRow As Integer

StartRow = 1
EndRow = StartRow + 3

Sheets("Master").Select
Rows("1:4").Select 'STATIC version of what I want
Rows("StartRow:EndRow").Select ' Dynamic vers of it



*** Sent via Developersdex http://www.developersdex.com ***



All times are GMT +1. The time now is 05:56 PM.

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