![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: NSW. Australia
Posts: 64
|
I have the following code in a userform.
Option Explicit Dim rownumber As Integer Private Sub cmdUndoAddRecord_Click() Cells("rownumber, 1: rownumber, 26").Select What I want to do is select a range of cells based on the variable rownumber. The above code returns the runtime error 13. I also tried the following code Range("rownumber, 1: rownumber, 26").Select This returned a global variable error. Does anyone know what code I can use here? Thanks in advance |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: NSW. Australia
Posts: 64
|
Problem solved
Range(Cells(rownumber, 1), Cells(rownumber, 26)).Select Thanks |
|
|
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Hi Phil, not sure how you set your [row] variable, but you'll want your variables outside of the quotes and fixed text (strings as we say in vba) in quotes. I use long on my row definitions in the case that the row variable is greater than 32k.
Try a procedure like below: Sub Sl() Dim rownumber As Long rownumber = Range("a65536").End(xlUp).Row 'delete this line Range("a" & rownumber & ":z" & rownumber).Select End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|