Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Define the irownumber

Option Explicit
Dim iRowNumber As Integer
Private Sub CommandButton1_Click()

Call PutData
Range("DataBase").Resize(Range("Database").Rows.Co unt + 1).Name =
"DataBase"
iRowNumber = Range("DataBase").Rows.Count

Call GetData
TextBox1.SetFocus

End Sub
Sub PutData()
With UserForm2
Range("DataBase").Cells(iRowNumber, 5) = .TextBox1
End With
End Sub
Sub GetData()
With UserForm1
.TextBox1 = Range("DataBase").Cells(iRowNumber, 5)
End With
End Sub
Private Sub CommandButton2_Click()
Unload UserForm2
End Sub

Hello
Altough i defined the irownumber as an integer and as the rows count when i
ask to put the data into the cell(irownumber,5), debug.
The irownumber sets equal to zero so it cannot find a cell (0,5).
Can you pleaze help me to find out what's wrong

Thanks in advance

Regards
Angeliki

PS. I used the same code for something relevant and it worked.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Define the irownumber

Angeliki,

PutData is executing before you set the irownumber variable. I'd also
suggest using a long variable for rows. Integer can fail on a big sheet.

Try it as

Private lRowNumber as long

Private Sub CB1_Click
lRowNumber = range("Database").rows.count +1
PutData
Range("Database).resize etc.

Yours,

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Angeliki" wrote in message
...
Option Explicit
Dim iRowNumber As Integer
Private Sub CommandButton1_Click()

Call PutData
Range("DataBase").Resize(Range("Database").Rows.Co unt + 1).Name =
"DataBase"
iRowNumber = Range("DataBase").Rows.Count

Call GetData
TextBox1.SetFocus

End Sub
Sub PutData()
With UserForm2
Range("DataBase").Cells(iRowNumber, 5) = .TextBox1
End With
End Sub
Sub GetData()
With UserForm1
.TextBox1 = Range("DataBase").Cells(iRowNumber, 5)
End With
End Sub
Private Sub CommandButton2_Click()
Unload UserForm2
End Sub

Hello
Altough i defined the irownumber as an integer and as the rows count when

i
ask to put the data into the cell(irownumber,5), debug.
The irownumber sets equal to zero so it cannot find a cell (0,5).
Can you pleaze help me to find out what's wrong

Thanks in advance

Regards
Angeliki

PS. I used the same code for something relevant and it worked.





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
Define a Value sagenichole Excel Worksheet Functions 2 May 18th 10 02:41 PM
Define Name rml Excel Worksheet Functions 5 November 9th 06 01:33 PM
Define name digicat Excel Discussion (Misc queries) 6 January 19th 06 05:54 PM
Name Define Ken Johnston Excel Discussion (Misc queries) 6 January 8th 06 03:04 PM
Define name Q Benjamin Excel Discussion (Misc queries) 3 October 19th 05 01:29 PM


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

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"