Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Select column that matches a value entered in a User Form TextBox

I am building an Excel 2007 User Form in VB. I want my users to be able to
type the day of month (i.e. 6 for the 6th of the month) and have code that
automatically selects the column that is set up for that date to be used.
Each column has the day of the month as the top field of the column.
Therefore, if they type '6', I want to select the equal value, '6' in the day
column, and use that column. Have tried several functions, and am not coming
up with the correct code to accomplish this.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Select column that matches a value entered in a User Form TextBox

I assume you meant "6" inthe day row, not column. Assuming I'm right, and
few other assumptions, then

dim C as integer
C = userform1.textbox1.text
if c = 0 then
msgbox "enter a number"
exit sub
end if
'assuming your entries are in row 1, and start in column B, since column A
is likely to be a title column, then:
Cells(1,C+1).select

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"Gwyzor" wrote in message
...
I am building an Excel 2007 User Form in VB. I want my users to be able to
type the day of month (i.e. 6 for the 6th of the month) and have code that
automatically selects the column that is set up for that date to be used.
Each column has the day of the month as the top field of the column.
Therefore, if they type '6', I want to select the equal value, '6' in the
day
column, and use that column. Have tried several functions, and am not
coming
up with the correct code to accomplish this.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Select column that matches a value entered in a User Form TextBox

Something like this maybe...

Sub AutoFitRowHeightWhenNecessary()
Dim R As Range
Dim CurrentHeight As Double
Const MinRowHeight As Double = 51
On Error GoTo Whoops
Application.ScreenUpdating = False
For Each R In Worksheets("Sheet1").UsedRange.Rows
R.AutoFit
If R.RowHeight < MinRowHeight Then
R.RowHeight = MinRowHeight
End If
Next
Whoops:
Application.ScreenUpdating = True
End Sub

--
Rick (MVP - Excel)


"Gwyzor" wrote in message
...
I am building an Excel 2007 User Form in VB. I want my users to be able to
type the day of month (i.e. 6 for the 6th of the month) and have code that
automatically selects the column that is set up for that date to be used.
Each column has the day of the month as the top field of the column.
Therefore, if they type '6', I want to select the equal value, '6' in the
day
column, and use that column. Have tried several functions, and am not
coming
up with the correct code to accomplish this.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Select column that matches a value entered in a User Form TextBox

Hi Gwyzor,

The following code may get you on the right track. It is a simple macro that
asks the user to specify the day of the month, and then activates the cell in
the appropriate column just below the last used cell. With this particular
code, you don't even have to have header values that correspond to the days
of the months. Regardless of what's in the first row, this code will select
the appropriate column:

'code starts:

Sub SelectColumn()
Dim DayNum As Integer
DayNum = InputBox("Please input today's" & vbNewLine & "day of the month")
Cells(Cells(Rows.Count, DayNum).End(xlUp).Row + 1, DayNum).Activate
End Sub

'code ends

HTH

"Gwyzor" wrote:

I am building an Excel 2007 User Form in VB. I want my users to be able to
type the day of month (i.e. 6 for the 6th of the month) and have code that
automatically selects the column that is set up for that date to be used.
Each column has the day of the month as the top field of the column.
Therefore, if they type '6', I want to select the equal value, '6' in the day
column, and use that column. Have tried several functions, and am not coming
up with the correct code to accomplish this.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Select column that matches a value entered in a User Form TextBox

Sorry... it looks like I posted my response to the wrong message thread.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Something like this maybe...

Sub AutoFitRowHeightWhenNecessary()
Dim R As Range
Dim CurrentHeight As Double
Const MinRowHeight As Double = 51
On Error GoTo Whoops
Application.ScreenUpdating = False
For Each R In Worksheets("Sheet1").UsedRange.Rows
R.AutoFit
If R.RowHeight < MinRowHeight Then
R.RowHeight = MinRowHeight
End If
Next
Whoops:
Application.ScreenUpdating = True
End Sub

--
Rick (MVP - Excel)


"Gwyzor" wrote in message
...
I am building an Excel 2007 User Form in VB. I want my users to be able
to
type the day of month (i.e. 6 for the 6th of the month) and have code
that
automatically selects the column that is set up for that date to be used.
Each column has the day of the month as the top field of the column.
Therefore, if they type '6', I want to select the equal value, '6' in the
day
column, and use that column. Have tried several functions, and am not
coming
up with the correct code to accomplish this.



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
Automatically add a textbox to a user form based on user requireme Brite Excel Programming 4 April 7th 07 11:37 PM
Textbox in user form Curt Excel Programming 2 February 20th 07 12:45 AM
macro that takes data entered in a user form textbox to go to a ra BrianMo Excel Programming 5 September 22nd 06 03:52 PM
User Form in VB = TextBox Kel Excel Discussion (Misc queries) 1 August 11th 05 12:26 AM
Format data entered with User Form Candee[_32_] Excel Programming 0 September 13th 04 06:13 PM


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