Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Assign cell to checkbox

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Assign cell to checkbox

Try this.

For i = 1 To 5
ActiveSheet.Shapes("Check Box" & i).Select
With Selection
.Value = xlOff
.LinkedCell = "A" & i
.Display3DShading = False
End With
Next i

End Sub

"Boss" wrote:

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Assign cell to checkbox

Gettign error.
Boss

"JLGWhiz" wrote:

Try this.

For i = 1 To 5
ActiveSheet.Shapes("Check Box" & i).Select
With Selection
.Value = xlOff
.LinkedCell = "A" & i
.Display3DShading = False
End With
Next i

End Sub

"Boss" wrote:

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Assign cell to checkbox

This only changes the linkedcell:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iCtr As Long
Dim TestCBX As CheckBox

Set wks = ActiveSheet

For iCtr = 1 To wks.CheckBoxes.Count
Set TestCBX = Nothing
On Error Resume Next
Set TestCBX = wks.CheckBoxes("Check Box " & iCtr)
On Error GoTo 0

If TestCBX Is Nothing Then
MsgBox "Name Error!!!"
Exit For
Else
TestCBX.LinkedCell = wks.Cells(iCtr, "A").Address(external:=True)
End If
Next iCtr

End Sub


Boss wrote:

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Assign cell to checkbox

Its working properly..
Can we even code in manner which will first insert a checkbox and then
assign cell to it.
Thanks a lot for ur help.
Boss

"Dave Peterson" wrote:

This only changes the linkedcell:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iCtr As Long
Dim TestCBX As CheckBox

Set wks = ActiveSheet

For iCtr = 1 To wks.CheckBoxes.Count
Set TestCBX = Nothing
On Error Resume Next
Set TestCBX = wks.CheckBoxes("Check Box " & iCtr)
On Error GoTo 0

If TestCBX Is Nothing Then
MsgBox "Name Error!!!"
Exit For
Else
TestCBX.LinkedCell = wks.Cells(iCtr, "A").Address(external:=True)
End If
Next iCtr

End Sub


Boss wrote:

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Assign cell to checkbox

Here's something that may help you get started:

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("B3:B10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With

Next myCell
End With
End Sub



Boss wrote:

Its working properly..
Can we even code in manner which will first insert a checkbox and then
assign cell to it.
Thanks a lot for ur help.
Boss

"Dave Peterson" wrote:

This only changes the linkedcell:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iCtr As Long
Dim TestCBX As CheckBox

Set wks = ActiveSheet

For iCtr = 1 To wks.CheckBoxes.Count
Set TestCBX = Nothing
On Error Resume Next
Set TestCBX = wks.CheckBoxes("Check Box " & iCtr)
On Error GoTo 0

If TestCBX Is Nothing Then
MsgBox "Name Error!!!"
Exit For
Else
TestCBX.LinkedCell = wks.Cells(iCtr, "A").Address(external:=True)
End If
Next iCtr

End Sub


Boss wrote:

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Assign cell to checkbox

This was Awesome..
You made my day.. !!

Thanks Thanks Thanks a lot.
Boss


"Dave Peterson" wrote:

Here's something that may help you get started:

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("B3:B10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With

Next myCell
End With
End Sub



Boss wrote:

Its working properly..
Can we even code in manner which will first insert a checkbox and then
assign cell to it.
Thanks a lot for ur help.
Boss

"Dave Peterson" wrote:

This only changes the linkedcell:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iCtr As Long
Dim TestCBX As CheckBox

Set wks = ActiveSheet

For iCtr = 1 To wks.CheckBoxes.Count
Set TestCBX = Nothing
On Error Resume Next
Set TestCBX = wks.CheckBoxes("Check Box " & iCtr)
On Error GoTo 0

If TestCBX Is Nothing Then
MsgBox "Name Error!!!"
Exit For
Else
TestCBX.LinkedCell = wks.Cells(iCtr, "A").Address(external:=True)
End If
Next iCtr

End Sub


Boss wrote:

I have 80 check box in a worksheet.
I wish to assign A1 to check box 1, A2 to check box 2.... so on and so forth.

I wrote a stupid code, please assit me with a correct one.

Sub Macro1()

For i = 1 To 5
ActiveSheet.Shapes("Check Box i").Select
With Selection
.Value = xlOff
.LinkedCell = "Ai"
.Display3DShading = False
End With
Next i

End Sub

Thanks a lot for ur help !!
Boss

--

Dave Peterson


--

Dave Peterson

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
Assign Color to a Cell based on another Cell on a diff Sheet VROSARIO7 Excel Worksheet Functions 2 July 6th 09 08:53 PM
ASSIGN VALUE TO CHECKBOX AND CALCULATE AVERAGE? nickee New Users to Excel 2 January 10th 09 09:44 PM
I want to place a checkbox in the middle of a cell, yet I want thecheckboxArea take up the entire cell. Leonid L Excel Discussion (Misc queries) 2 July 30th 08 04:25 PM
Assign Macro to Checkbox jafsonic Excel Programming 8 November 8th 06 12:06 AM
How do i assign cell A1 to show the current cursor cell in Excel? OB Excel Discussion (Misc queries) 2 October 11th 06 04:02 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"