Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If Then to Add Row


I have written the following code to add a row based on the numbe
selected by the user via a spinbutton.

Sub AddRow()
If Sheets("Sheet1").Range("B3").Value = "2" Then Rows("4:10").Selec
Selection.EntireRow.Hidden = True
If Sheets("Sheet1").Range("B3").Value = "1" Then Rows("4:10").Selec
Selection.EntireRow.Hidden = False
End Sub

The function does not work and I would appreciate any assistance.
would also like the code to fire each time the spinbutton is changed.

Thank

--
bforster
-----------------------------------------------------------------------
bforster1's Profile: http://www.excelforum.com/member.php...fo&userid=1177
View this thread: http://www.excelforum.com/showthread.php?threadid=26435

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default If Then to Add Row

bforster1,

Your code would only hide and unhide rows, it doesn't insert. Use the macro
recorder and insert a row to get a start on some code.

To have it fire on a spinbutton change, you need to use a spinbutton from
the Control Toolbox - not the Forms toolbar. Then just double-click on the
spinbutton when you are in design mode and insert the code into the module
that appears (it will be the worksheet module for the sheet the button is
in). The code window will look something like this:

Private Sub SpinButton1_Change()

'insert your code here

End Sub

hth,

Doug Glancy

"bforster1" wrote in message
...

I have written the following code to add a row based on the number
selected by the user via a spinbutton.

Sub AddRow()
If Sheets("Sheet1").Range("B3").Value = "2" Then Rows("4:10").Select
Selection.EntireRow.Hidden = True
If Sheets("Sheet1").Range("B3").Value = "1" Then Rows("4:10").Select
Selection.EntireRow.Hidden = False
End Sub

The function does not work and I would appreciate any assistance. I
would also like the code to fire each time the spinbutton is changed.

Thanks


--
bforster1
------------------------------------------------------------------------
bforster1's Profile:

http://www.excelforum.com/member.php...o&userid=11771
View this thread: http://www.excelforum.com/showthread...hreadid=264351



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



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