Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This Macro CAN'T be that difficult can it?

Status
Not open for further replies.

Swoosh

Technical User
May 31, 2001
6
US
Okay, here's the situation: I have two sheets sheet ONE is to input data and information on a daily basis, So when the following day comes new data takes it's place. However, after entering the current days information, I would like to go to Sheet TWO where column a is filled with progressive dates and column b is a category header, so is c, d, e, f, and g which are supposed to list the Results of what Sheet A is displaying....

Now here is the problem: I can do a macro that will insert all totals into the correct and current date of information put on Sheet ONE....however, how to I make a macro that will put the information into the correct ROW of that current date without it effecting the previous dates totals. HELP WOULD BE BEYOND APPRECIATED!!!!
 
You need to write a macro that searches in Column A in sheet TWO for the same date as sheet ONE.

you can either use the find function then return the activecell.row

or you can use a For loop from i=2 to number of lines comparing the Value in (A & i) with the required date then just return i.


Then use this value to paste the data into the correct row.
 
I'm not much of a programmer, so I guess this is more difficult than I expected...btw, sheet ONE contains only the current date.....when the following day arrives...it is REPLACED with that days date....unlike sheet TWO which has all dated for that year in sequential order.....Thank You so much for the quick response....I wish I had ya here
 
If you send an example spreadsheet to my email address I could set up an example for you tomorrow.

dark_suns@lycos.com
 
WoW, that would be Great!.....Thank you so much for the consideration and effort, I'll start working on putting comments onto certain cells or maybe even color code them so that it will be easier to identify which Total goes with what on Sheet TWO....Thanks again.
 
I'm in the UK so when i said tomorrow it means tonight for you (I assume you are in the States). So if you email me the file today I will have a look at it.
 
Okay, file is already sent.......I know I've been saying this alot but THANKS, I can't wait to see what you come up with..and yes I am from the States (PA)
 
I have emailed you the file.

Here is the code for everyone else:

Private Sub CmdGetData_Click()
Dim DataSheetName As String
Dim DataHistorySheetName As String
Dim MyRow As Integer

DataSheetName = Sheet1.Name
DataHistorySheetName = Sheet2.Name

With ActiveSheet.Range("B:B")
Set c = .Find(Worksheets(DataSheetName).Range("A2").Value, LookIn:=xlValues)
If Not c Is Nothing Then
MyRow = c.Row
Else
MyRow = 0
End If
End With

If MyRow <> 0 Then
With ActiveSheet
.Range(&quot;C&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;B31&quot;).Value
.Range(&quot;D&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;B19&quot;).Value
.Range(&quot;E&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;B21&quot;).Value
.Range(&quot;F&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;E17&quot;).Value
.Range(&quot;G&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;E19&quot;).Value
.Range(&quot;H&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;B17&quot;).Value
.Range(&quot;I&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;B18&quot;).Value
'.Range(&quot;J&quot; & MyRow).Value = Worksheets(DataSheetName).Range(&quot;B31&quot;).Value

End With
Else
MsgBox &quot;Unable to find Date&quot;
End If

End Sub
 
Dark Sun....I get an error message stating &quot;Unable to Get the Find Property of the Range Class&quot; when I try to execute it. I was soooooooooo like crossing my fingers when I went to try it.....Is this an easy fix?.....and wow, your even considerate enough to ask if I want some of the code explained to me. You are truly a gem with your geniune efforts....I'll wait to see if you read this and can come up with anything.
 
Hmm, I think that is because I programmed it in 2000 and left out a line that it needed. I have changed my approach, I have sent you the new file. Sorry about that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top