Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Insert formula based on input box

You're right. Thanks for the help!

"Daniel.C" wrote:

Try :

Sub test()
Dim Dat As Date, myRow As Long, i As Long, Col As Integer
Col = Range("IV1").End(xlToLeft).Column
Dat = CDate(InputBox("Enter date"))
If IsNumeric(Application.Match(Dat * 1, [A2:A65000], 0)) Then
[A1] = Dat
myRow = Application.Match(Dat * 1, [A2:A65000], 0) + 1
For i = 2 To Col
Cells(myRow, i).Formula = _

"=IF($A4=HOURS!$A$1,INDEX(HOURS!$G:$G,MATCH(B$1,HO URS!$A:$A,0)),"""")"
Next i
End If
End Sub

Regards.
Daniel

There are two sheets: "Hours" and "Table"
In my program, there is an input box that pops up and asks the user for a
date. This date will be inputted into $A$1 of the Hours tab.

In the Table tab, there is a list of employees and all the dates for the
year. (Employees in columns, and dates in the rows).

If the date in Column A of the Table tab matches the date in $A$1 of the
Hours tab, I want to enter a lookup formula in each column of the row that
matches (but ONLY in that particular row).

For example:

A B C D E
Ed Matt Dave Sam
1/1/09
1/2/09
1/3/09 "formula" "formula" "formula" "formula"
1/4/09

So, when the user entered "1/3/09" in the input box on the Hours tab for
$a$1, it found it on the Table tab and entered the formula for the entire row
that 1/3/09 was found on.

(if it helps, the formula is going to be something along the lines of
=IF($A4=HOURS!$A$1,INDEX(HOURS!$G:$G,MATCH(B$1,HOU RS!$A:$A,0)),"")
basically just to return the total hours after matching the employee number
and the date.

I started writing some kind of looping search, but it doesn't seem to work.

Any help is appreciated!




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
YTD budget formula based on current actual input Sanj Excel Worksheet Functions 4 June 10th 09 06:04 PM
formula pulling data based on 1 input on another tab. bmo Excel Worksheet Functions 0 October 9th 07 08:22 PM
insert a picture based on a formula Analyst Excel Worksheet Functions 1 July 20th 06 01:07 PM
Macro to insert cells based on an input Mark64 Excel Programming 0 March 9th 06 02:01 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


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