ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA Form error message (https://www.excelbanter.com/excel-programming/360691-excel-vba-form-error-message.html)

ll

Excel VBA Form error message
 
Hi,
I am working with a VBA form in Excel, and the code for the form
includes several sub's. In one of the subs, I set variable "c" equal
to the value of "i" which has been looping, so that, at the end of the
loop through the rows, "c" will equal the last row number. I want to
temporarily store the value of c in a cell. Here's the code for that:

c = i
Cells(1, 26).Value = c

Next, in the same form code, but another sub, I want to assign the
value in the previously mentioned cell (plus 7) to variable "i". See
code below:

i = Sheet1.Cells(1, 26).Value + 7

The problem is that I'm getting an error message that points to the
line in the first sub <Cells(1,26).Value=c. Is there a problem with
syntax, etc?

Thanks,
Louis


Tom Ogilvy

Excel VBA Form error message
 
Normally I wouldn't see it as a problem, but try

Sheet1.Cells(1, 26).Value = c

--
Regards,
Tom Ogilvy



"ll" wrote in message
ups.com...
Hi,
I am working with a VBA form in Excel, and the code for the form
includes several sub's. In one of the subs, I set variable "c" equal
to the value of "i" which has been looping, so that, at the end of the
loop through the rows, "c" will equal the last row number. I want to
temporarily store the value of c in a cell. Here's the code for that:

c = i
Cells(1, 26).Value = c

Next, in the same form code, but another sub, I want to assign the
value in the previously mentioned cell (plus 7) to variable "i". See
code below:

i = Sheet1.Cells(1, 26).Value + 7

The problem is that I'm getting an error message that points to the
line in the first sub <Cells(1,26).Value=c. Is there a problem with
syntax, etc?

Thanks,
Louis




ll

Excel VBA Form error message
 
Thanks for your help,
The looping does work, but the error comes up after all of the looping
is performed, Thanks.

Here's the code:
-----------------------
d = 1
For i = 8 To 3000
Cells(1, 26).Clear

If i = d + 1 Then
Exit Sub
End If

'////the following puts the values from the excel vba form into certain
cells
If Sheets("Sheet1").Cells(i, 1).Value = "" Then
Sheets("Sheet1").Cells(i, 1).Value = frmBkCheckout.txtName.Value
Sheets("Sheet1").Cells(i, 2).Value = frmBkCheckout.cboEmail.Value
Sheets("Sheet1").Cells(i, 3).Value = frmBkCheckout.cboCourse2.Value
Sheets("Sheet1").Cells(i, 4).Value =
frmBkCheckout.txtDateCheckedOut.Value

d = i
Sheet1.Cells(1, 26).Value = d
End If
Next


ll

Excel VBA Form error message
 
Would the loop be looking for more info from the form to put into the
next line?



All times are GMT +1. The time now is 11:27 AM.

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