View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Using macros to "find" data and use that as a reference

You need to explain more about your data layout. Is the input data in
the range B2:C20 related to a single date and if so what cell is that
date in? Or are there multiple dates on the input data sheet? What I
need to know is the exact layout of the Inupt and Data sheets.

Regards
Rowan

PS Please keep all correspondence in the newsgroup.

Agasnine wrote:
Thanks a lot! 1 question. How do I get the "inpData =
Sheets("Input").Range("B2").Value" to recognise a range or cells? as in
B2:C20. When I try to input B2:C20, it gives this error "Run-time error '13'
: Type mismatch". Any thoughts? Thanks


"Rowan Drummond" wrote:


Assumptions:
On the input sheet the date is entered into Cell A2 and the data is
enterd into cell B2.
On the Main sheet the list of dates is in column A and the data should
be inserted into column B.

Sub finder()
Dim fDate As Date
Dim fndRng As Range
Dim inpData As String

fDate = Sheets("Input").Range("A2").Value
inpData = Sheets("Input").Range("B2").Value
With Sheets("Main").Columns(1)
Set fndRng = .Find(fDate)
End With
If Not fndRng Is Nothing Then
fndRng.Offset(0, 1).Value = inpData
End If
End Sub


Hope this helps
Rowan

Agasnine wrote:

I am using Excel 2003 but need this to work in Excel '97.
On a "Main" sheet I have a series of dates with data the is inserted below
the dates. On an "Input" sheet I have a "data input" section with the date,
and the data for that date.
This is what I want to do.

Input a date, type the data for that date, click a button to activate a
macro or a series of macros. The macro would take the date from the "Input"
sheet and find it on the "Main" sheet. Then it would take the data from the
"Input" sheet and insert it on the "Main" sheet.
The problem I am running into is getting the macro to "find" the date in the
"Main" sheet and use that as a reference as to where to paste the data.