Retrieving data from database

Pericic

Board Regular
Joined
Nov 11, 2005
Messages
204
Is there a way to retrieve data from a database based on date values??

I have a database on sheet 1 whose values change daily...(cumulative database)

I would like to preserve data on a separate sheet for each day...that is get the data from the database today, and keep it before it changes tomorrow??
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello Pericic,
Sure, there are a number of ways to do that. The best of which would depend on possibly several factors, such as if you want to keep today's data on sheet2 (for example) and then overwrite it tomorrow with tomorrow's data or if you want each day's data to go (again in sheet2) below the previous day's data, or perhaps each day to a seperate sheet, or...(?)
What column(s) do you want to copy to the other sheet(s)?

If you can give us as many specific details as you can think of, as to what you want to do we can come up with a much more meaningful example of how to do it.
 
Upvote 0
Thanks for such a quick response...
I want to keep the data, I do not want to overwrite it...

I'd like each days data to go below previous days data..(doesn't really matter what column...

Once again thanks for your help halface
 
Upvote 0
OK, (without more details) I'm having to make several assumptions here.
(1) This code will be run from the sheet you are copying from.
(2) You are only (ever) interested in copying the data specific to the current date at the time.
(3) Your dates are all in column A.
(4) You want to copy the entire row(s) for the day to the destination sheet.
(5) Your destination sheet is sheet2.

If all of these are acceptable then you should be able to use something like this:
Code:
Sub CopyDemo()
Dim SrchRng As Range, CpyRow As Range, c As Range
Set SrchRng = Range(Cells(1, 1), (Cells(Rows.Count, 1).End(xlUp)))

For Each c In SrchRng
    If c.Value = Date Then
        If CpyRow Is Nothing Then
            Set CpyRow = c
          Else: Set CpyRow = Union(c, CpyRow)
        End If
    End If
Next c

If Not CpyRow Is Nothing Then CpyRow.EntireRow.Copy _
    Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp)(2, 1)

End Sub
If this isn't doing what you want, or isn't close enough to be able to edit it to what you need you'll have to provide more details such as copy what, from where, to where, etc.

Hope it helps.
 
Upvote 0
OK, I see I need an example...

A1 is today

C7:G13 is my input data (input daily)

C1:G5 is the dynamic database....

I need to copy these database values for 12/27 to sheet 2 as they are now......
When I input values for 12/28 the database values will change.....but I dont want the copied values on sheet 2 for 12/27 to change....I'd like to repeat this process on a daily basis....

Thanks again for your time and expertise
Book1
ABCDEFG
112/27/200546789
246789
346789
446789
546789
6
726-Dec34444
827-Dec12345
928-Dec
1029-Dec
1130-Dec
1231-Dec
131-Jan
DB
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,344
Members
448,956
Latest member
Adamsxl

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