Macro or Lookup?

Utradeshow

Well-known Member
Joined
Apr 26, 2004
Messages
769
Hi Guys, I have a workbook on SHEET 1 I have a running database actually a tracking system. It consiststs of COLUMNS "A" through "J"

Colums G through J have dates in them. I am looking to see if I can have sheet 2 have an input cell where I enter the date and it will list the rows containing the dates? Here is an example of the first sheet.
Trio Tracking 2006 Test.xls
ABCDEFGHIJ
212345B.E.CustomerClient01/03/0601/04/0601/07/0601/07/06
3901508B.E.CustomerClient01/03/0601/04/0601/07/0601/07/06
4901509B.E.CustomerClient01/03/0601/04/0601/07/0601/07/06
TRADESHOW
 
1. I just can't seem to make it run automatically.
2. Also if it could copy out to column "M" I think it would be perfect.
1. what do you mean, when the dates are changed ?
2. do you mean you want to copy columns A to M ?
then just change "J" to "M" in the line with COPY

greetings,
Erik
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Ok, Almost perfect... I changed it to copy to "M" works great.
I'm finding out I only need the code to Look at The dates in "H" and "J" can we change that?
And I still have to make it run Manually. I placed the code in the"Weekend" sheet?
 
Upvote 0
only H and J
edit the line with "Range("G" & i & ":J" & i)"
with a comma instead of the colon
test this
Code:
Range("H2:J2").Select
Range("H2,J2").Select
you need
Code:
Range("H" & i & ",J" & i)

And I still have to make it run Manually. I placed the code in the"Weekend" sheet?
perhaps my question wasn't well worded
when do you want to run the code: is it when you change one of the dates ?
Then there is a problem to solve. When you want to change the dates, the code may not run when you didn't change both. Would it be good to force the user to clear before he can fill in a next date.-?

the code can then be place in th worksheetchange-event, with a few tweaks ...
 
Upvote 0
Eric,

Ok, Here is the final product that works awesome!!! The only thing is I have the input cells in row 1, then the code places the result in rows 2 DOWN. is there a way to have it start at about row 5?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$H$1" Then Exit Sub
If Len(Target.Value) = 0 Then Exit Sub
Dim TradeSh As Worksheet
Dim WeekendSh As Worksheet
Dim TradeLR As Long
Dim WeekendLR As Long
Dim i As Long
Dim c As Range
Dim StartDate As Date
Dim EndDate As Date
Dim FindDate As Date
Dim AppSetCalc As Integer

Set TradeSh = Sheets("TRADESHOW")
Set WeekendSh = Sheets("WEEKEND")

    With WeekendSh
    .Range("A2:M" & Rows.Count).Delete
    StartDate = .Range("G1").Value
    StartDate = DateSerial(Year(StartDate), Month(StartDate), Day(StartDate))
    EndDate = .Range("H1").Value
    EndDate = DateSerial(Year(EndDate), Month(EndDate), Day(EndDate))
    
    End With
    
    With Application
    .ScreenUpdating = False
    AppSetCalc = .Calculation
    .Calculation = xlCalculationManual
    End With

    With TradeSh
    TradeLR = .Cells.Find("*", .[A1], xlFormulas, xlPart, xlByRows, xlPrevious, False, False).Row
        For i = 2 To TradeLR
        Set c = Nothing
            For FindDate = StartDate To EndDate
            Set c = .Range("H" & i & ",J" & i).Find(FindDate)
                If Not c Is Nothing Then
                .Range(.Cells(i, "A"), .Cells(i, "M")).Copy WeekendSh.Cells(Rows.Count, "A").End(xlUp)(2)
                Exit For
                End If
            Next FindDate
        Next i

    End With
    
    With Application
    .ScreenUpdating = True
    .Calculation = AppSetCalc
    Columns("G:J").NumberFormat = "m/d;@"
    
    End With

End Sub
 
Upvote 0
to make it start at row 5 you could insert some formulas & extra lines (my prefered strategy :) )
or you could use a simple trick
put something in row 4 before the action takes place
after action delete it: so simple

Code:
    With TradeSh 
    .Range("A4") = "something "

    TradeLR = ....
    ....

    .Range("A4") = ""
    End With

greetins from Belgiums,
Erik
possibly without internet-connection within 2 hours till 22th sept
 
Upvote 0

Forum statistics

Threads
1,215,754
Messages
6,126,680
Members
449,328
Latest member
easperhe29

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top