Checkbox issues

joeyjj

Board Regular
Joined
Aug 12, 2010
Messages
62
Hello all,

I have the following code which I keep receiving errors with.

PHP:
If ChBLine = True Then

iRow = ws.Range(ActiveCell.Address)

Else

If ws.Range("A2").Value <> "" Then
    iRow = ws.Range("A1").End(xlDown).Row + 1
Else
    iRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
End If
End If

Note that ChBLine is the name of a check box.

I would like the code to be such that if the user checks the box then iRow becomes whatever cell the user is on, otherwise I want it to find the next available cell.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I would also like to add that the printing format to sent to the spreadsheet is as follows:

PHP:
ws.Cells(iRow, 1).Font.Bold = True
ws.Cells(iRow, 1).Value = "Duct"
ws.Cells(iRow, 2).NumberFormat = 0
ws.Cells(iRow, 2).Value = -LD63
ws.Cells(iRow, 3).NumberFormat = 0
ws.Cells(iRow, 3).Value = -LD125
ws.Cells(iRow, 4).NumberFormat = 0
ws.Cells(iRow, 4).Value = -LD250
ws.Cells(iRow, 5).NumberFormat = 0
ws.Cells(iRow, 5).Value = -LD500
ws.Cells(iRow, 6).NumberFormat = 0
ws.Cells(iRow, 6).Value = -LD1000
ws.Cells(iRow, 7).NumberFormat = 0
ws.Cells(iRow, 7).Value = -LD2000
ws.Cells(iRow, 8).NumberFormat = 0
ws.Cells(iRow, 8).Value = -LD4000
ws.Cells(iRow, 9).NumberFormat = 0
ws.Cells(iRow, 9).Value = -LD8000
 
Upvote 0
After playing around with it a bit more i found the problem. See the coding below:

PHP:
If ChBLine = True Then

iRow = ActiveCell.Row

Else

If ws.Range("A2").Value <> "" Then
    iRow = ws.Range("A1").End(xlDown).Row + 1
Else
    iRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
End If
End If
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top