user input with text box?

fahimip

New Member
Joined
Sep 27, 2006
Messages
35
Hi guys

I am wanting to write code for a spreadsheet in the following layout
the columns are week numbers (1-52)
and the rows are names

WEEK 1 2 3 4 5 6 7 8 9 10 11 12
NAME
paul 32 7 7
tim 4
tommy 5 5 5
john 1 5 7 7 69 5
ivan 54 5 36
george 2 20 5
mario 3 5 4
mark 5 2 88
tom 66 1 3
graham 5 5
chris 56 8
elaine 8 3
matt




The code i need to write will ask the user which week he/she is inputting into and then only input data into that particular column. the data will be derived from another worksheet.


the thing that confuses me is how to program vba so that it will input in the right column depending on the week no. chosen


Thanks for your help
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

bbrnx19

Board Regular
Joined
Oct 25, 2006
Messages
148
hi fahimip
will this do
Code:
Sub test()
Dim WeekNo As Integer
Dim ColumnNo As Integer
Worksheets("Sheet1").Activate
WeekNo = Application.InputBox( _
    prompt:="Input Week Number data to be entered (1-52)", _
    Title:="Week Number", Type:=1)

ColumnNo = WeekNo + 1
 
    Worksheets("sheet1").Cells(2, ColumnNo) = "some data"
    Worksheets("sheet1").Cells(3, ColumnNo) = "some data2"

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,113,953
Messages
5,545,153
Members
410,666
Latest member
forzasec
Top