Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Insert a square in a cell with VBA

Hi

I have a list in Excel 2007. I want to put a square to the right of some of
the list items. How can I do this with VBA.

The end user will see the list on a printout with square/checkbox in the
right column. The idea is that the end user should go thrue the list and
mark/check the items that he agrees on

Regards
JayDe
Norway
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Insert a square in a cell with VBA

Just put a border around the cell:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/16/2010 by James Ravenswood
'

'
Range("E8").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End Sub

--
Gary''s Student - gsnu200909


"JayDe" wrote:

Hi

I have a list in Excel 2007. I want to put a square to the right of some of
the list items. How can I do this with VBA.

The end user will see the list on a printout with square/checkbox in the
right column. The idea is that the end user should go thrue the list and
mark/check the items that he agrees on

Regards
JayDe
Norway

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Insert a square in a cell with VBA

Thank you for the answer.
But a border does not look at all like a checkbox, so I am not very happy
with that solution

JayDe

"Gary''s Student" wrote:

Just put a border around the cell:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/16/2010 by James Ravenswood
'

'
Range("E8").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End Sub

--
Gary''s Student - gsnu200909


"JayDe" wrote:

Hi

I have a list in Excel 2007. I want to put a square to the right of some of
the list items. How can I do this with VBA.

The end user will see the list on a printout with square/checkbox in the
right column. The idea is that the end user should go thrue the list and
mark/check the items that he agrees on

Regards
JayDe
Norway

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Insert a square in a cell with VBA

Then see:

http://groups.google.com/group/micro...106802f1803eb5

The Forms checkbox looks like a checkbox, it prints like a checkbox and you
can even check it in Excel.
--
Gary''s Student - gsnu200909


"JayDe" wrote:

Thank you for the answer.
But a border does not look at all like a checkbox, so I am not very happy
with that solution

JayDe

"Gary''s Student" wrote:

Just put a border around the cell:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/16/2010 by James Ravenswood
'

'
Range("E8").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End Sub

--
Gary''s Student - gsnu200909


"JayDe" wrote:

Hi

I have a list in Excel 2007. I want to put a square to the right of some of
the list items. How can I do this with VBA.

The end user will see the list on a printout with square/checkbox in the
right column. The idea is that the end user should go thrue the list and
mark/check the items that he agrees on

Regards
JayDe
Norway

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Insert a square in a cell with VBA

Expanding upon the macro that Dave Peterson wrote at the URL you were
pointed to................

Select the range of cells to the right of your list.

List of items in A1:A20

Select B1:B20 and run the macro.

Sub testme()
Dim mycell As Range
For Each mycell In Selection
On Error Resume Next
ActiveSheet.CheckBoxes("cb_" & mycell.Address(False, False)).Delete
On Error GoTo 0
With mycell
With ActiveSheet.CheckBoxes.Add(.Left, .Top, .Width, .Height)
.Name = "cb_" & mycell.Address(False, False)
.Caption = "Agree"
End With
End With
Next
End Sub


Gord Dibben MS Excel MVP

On Sat, 16 Jan 2010 05:42:01 -0800, JayDe
wrote:

Hi

I have a list in Excel 2007. I want to put a square to the right of some of
the list items. How can I do this with VBA.

The end user will see the list on a printout with square/checkbox in the
right column. The idea is that the end user should go thrue the list and
mark/check the items that he agrees on

Regards
JayDe
Norway




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Insert a square in a cell with VBA

Thank you guy's

This did the trick


JayDe



"Gord Dibben" wrote:

Expanding upon the macro that Dave Peterson wrote at the URL you were
pointed to................

Select the range of cells to the right of your list.

List of items in A1:A20

Select B1:B20 and run the macro.

Sub testme()
Dim mycell As Range
For Each mycell In Selection
On Error Resume Next
ActiveSheet.CheckBoxes("cb_" & mycell.Address(False, False)).Delete
On Error GoTo 0
With mycell
With ActiveSheet.CheckBoxes.Add(.Left, .Top, .Width, .Height)
.Name = "cb_" & mycell.Address(False, False)
.Caption = "Agree"
End With
End With
Next
End Sub


Gord Dibben MS Excel MVP

On Sat, 16 Jan 2010 05:42:01 -0800, JayDe
wrote:

Hi

I have a list in Excel 2007. I want to put a square to the right of some of
the list items. How can I do this with VBA.

The end user will see the list on a printout with square/checkbox in the
right column. The idea is that the end user should go thrue the list and
mark/check the items that he agrees on

Regards
JayDe
Norway


.

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
How do I a rotate my square radar chart (square-diamond)? Becs I Know Nathing Charts and Charting in Excel 5 April 3rd 23 07:30 PM
How to fit each cell into a perfect square? Eric Excel Discussion (Misc queries) 3 September 21st 07 07:15 AM
how to center a square plot area in a square chart xppuser Charts and Charting in Excel 2 March 11th 06 08:13 AM
Regression Output -- R Square versus Adjusted R Square Bonnie Excel Discussion (Misc queries) 1 October 25th 05 12:55 AM
Shapes.. trying to print a square square keepitcool Excel Programming 3 November 21st 03 04:55 AM


All times are GMT +1. The time now is 03:43 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"