MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 27th, 2002, 05:29 AM   #1
mikeyboy
Board Regular
 
Join Date: Apr 2002
Posts: 57
Default

Hi, Your assistance is much appreciated. I'm looking for code to copy "Cond Storage Sheet" cells A:F that have date/time equal to and ahead of current time. Cell A is the date and cell B is the time and paste the selected cells to "Pumping Report" cell C30.

The "Pumping Report" sheet is a handout given to controllers to perform actions according to the date and time annotated in cells A & B and extends as much as 48 hours into the future.

The "Cond Storage Sheet" is an ever increasing log of all the scheduled actions and is only added to 1 or 2 days in advance. Copying future date entries from the log is a convenient way to produce the required handout.

Thanks in advance

mikeyboy is offline   Reply With Quote
Old Apr 27th, 2002, 05:38 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Quote:
On 2002-04-27 04:29, mikeyboy wrote:
Hi, Your assistance is much appreciated. I'm looking for code to copy "Cond Storage Sheet" cells A:F that have date/time equal to and ahead of current time. Cell A is the date and cell B is the time and paste the selected cells to "Pumping Report" cell C30.

The "Pumping Report" sheet is a handout given to controllers to perform actions according to the date and time annotated in cells A & B and extends as much as 48 hours into the future.

The "Cond Storage Sheet" is an ever increasing log of all the scheduled actions and is only added to 1 or 2 days in advance. Copying future date entries from the log is a convenient way to produce the required handout.

Thanks in advance


Hi Mike...
To cell C30?
Is this always the same or will
the data need to be pasted on down
on an ongoing basis?

In essence, is this a one time paste to
"Pumping Report" cell C30?

Thanks,
Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 27th, 2002, 05:51 AM   #3
mikeyboy
Board Regular
 
Join Date: Apr 2002
Posts: 57
Default

C30 is always the same. I will be pasting over the previous "Pumping Report" C30 data with the latest and then printing out "Pumping Report" sheet to hand out to controllers.
Thanks

[ This Message was edited by: mikeyboy on 2002-04-27 04:56 ]
mikeyboy is offline   Reply With Quote
Old Apr 27th, 2002, 05:56 AM   #4
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

One more quick question...
I'm drumming up a procedure for you and wanted to make sure I understood the placement on "Pumping Report".

I'm assuming columns C to H?
Also, which row, on "Cond Storage Sheet", contains your first entry?
Another ?
Does the data need to be sorted on
"Pumping Report"? If so, by date and time?

Thanks,
Tom

[ This Message was edited by: TsTom on 2002-04-27 05:00 ]
Tom Schreiner is offline   Reply With Quote
Old Apr 27th, 2002, 06:01 AM   #5
mikeyboy
Board Regular
 
Join Date: Apr 2002
Posts: 57
Default

Tom, First entry on "Cond Storage Sheet" is A11.

And yes C:H is correct

The rows of data are entered from earlier to later on "Cond Storage Sheet" and they will need to be in the same early to later row order on "Pumping Report"

[ This Message was edited by: mikeyboy on 2002-04-27 05:05 ]
mikeyboy is offline   Reply With Quote
Old Apr 27th, 2002, 06:17 AM   #6
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Run from "Cond Storage Sheet"
This appears to work...
If not, repost and someone
will help you...
Tom



Sub CopyByDate()
Dim LastEntry As Long, Cntr As Long
Dim CheckDate As Variant
Dim IsCheckDate As Date
Dim PlaceCntr As Integer

LastEntry = Cells(Rows.Count, 1).End(xlUp).Row
PlaceCntr = 29
Sheets("Pumping Report").Range("C30:H1000").ClearContents
For Cntr = 11 To LastEntry
CheckDate = Cells(Cntr, 1) & " " & Format(Cells(Cntr, 2), "HH:MM")
If IsDate(CheckDate) Then
IsCheckDate = CheckDate
If Now > IsCheckDate Then
PlaceCntr = PlaceCntr + 1
Range("A" & Cntr & ":F" & Cntr).Copy _
Destination:=Sheets("Pumping Report").Range("C" & _
PlaceCntr & ":H" & PlaceCntr)
End If
End If
Next
End Sub





Tom Schreiner is offline   Reply With Quote
Old Apr 27th, 2002, 06:42 AM   #7
mikeyboy
Board Regular
 
Join Date: Apr 2002
Posts: 57
Default

Tom, I pasted your macro in the "Cond Storage Sheet" and ran the macro.

Two adjustments are needed.
1) Previous date/time cells are being pasted instead of future date/times.
2) Can the paste be changed to paste special so the format isn't carried along with the copied cells?

Thank you so much for helping here. I'll check back later.

mikeyboy is offline   Reply With Quote
Old Apr 27th, 2002, 07:03 AM   #8
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default




Sub CopyByDate()
Dim LastEntry As Long, Cntr As Long
Dim CheckDate As Variant
Dim IsCheckDate As Date
Dim PlaceCntr As Integer

LastEntry = Cells(Rows.Count, 1).End(xlUp).Row
PlaceCntr = 29
Sheets("Pumping Report").Range("C30:H1000").ClearContents
For Cntr = 11 To LastEntry
CheckDate = Cells(Cntr, 1) & " " & Format(Cells(Cntr, 2), "HH:MM")
If IsDate(CheckDate) Then
IsCheckDate = CheckDate
If Now <= IsCheckDate Then
PlaceCntr = PlaceCntr + 1
Sheets("Pumping Report").Range("C" & _
PlaceCntr & ":H" & PlaceCntr) = _
Range("A" & Cntr & ":F" & Cntr).Value
End If
End If
Next
End Sub




[ This Message was edited by: TsTom on 2002-04-27 06:04 ]
Tom Schreiner is offline   Reply With Quote
Old Apr 27th, 2002, 08:26 AM   #9
mikeyboy
Board Regular
 
Join Date: Apr 2002
Posts: 57
Default

Tom, Sheer genious!

Works terrific!!

Thank you so much.
mikeyboy is offline   Reply With Quote
Old Apr 27th, 2002, 02:13 PM   #10
mikeyboy
Board Regular
 
Join Date: Apr 2002
Posts: 57
Default

This excel sheet is a work in progress. The next step is to mesh these two macros so both can function as change events if possible. The first macro is to fill in time cells using keypad only. The second pastes certain cells to a different sheet for printout. Any ideas?

Thanks again


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim TimeStr As String

On Error GoTo EndMacro
If Application.Intersect(Target, Range("B1:B1000,I1:I1000,P1:P1000")) Is Nothing Then
Exit Sub
End If
If Target.Cells.Count > 1 Then
Exit Sub
End If
If Target.Value = "" Then
Exit Sub
End If

Application.EnableEvents = False
With Target
If .HasFormula = False Then
Select Case Len(.Value)
Case 1 ' e.g., 1 = 00:01 AM
TimeStr = "00:0" & .Value
Case 2 ' e.g., 12 = 00:12 AM
TimeStr = "00:" & .Value
Case 3 ' e.g., 735 = 7:35 AM
TimeStr = Left(.Value, 1) & ":" & _
Right(.Value, 2)
Case 4 ' e.g., 1234 = 12:34
TimeStr = Left(.Value, 2) & ":" & _
Right(.Value, 2)
Case 5 ' e.g., 12345 = 1:23:45 NOT 12:03:45
TimeStr = Left(.Value, 1) & ":" & _
Mid(.Value, 2, 2) & ":" & Right(.Value, 2)
Case 6 ' e.g., 123456 = 12:34:56
TimeStr = Left(.Value, 2) & ":" & _
Mid(.Value, 3, 2) & ":" & Right(.Value, 2)
Case Else
Err.Raise 0
End Select
.Value = TimeValue(TimeStr)
End If
End With
Application.EnableEvents = True
Exit Sub
EndMacro:
MsgBox "You did not enter a valid time"
Application.EnableEvents = True
End Sub





Sub CopyByDate()
Dim LastEntry As Long, Cntr As Long
Dim CheckDate As Variant
Dim IsCheckDate As Date
Dim PlaceCntr As Integer

LastEntry = Cells(Rows.Count, 1).End(xlUp).Row
PlaceCntr = 29
Sheets("Pumping Report").Range("C30:H1000").ClearContents
For Cntr = 11 To LastEntry
CheckDate = Cells(Cntr, 1) & " " & Format(Cells(Cntr, 2), "HH:MM")
If IsDate(CheckDate) Then
IsCheckDate = CheckDate
If Now <= IsCheckDate Then
PlaceCntr = PlaceCntr + 1
Sheets("Pumping Report").Range("C" & _
PlaceCntr & ":H" & PlaceCntr) = _
Range("A" & Cntr & ":F" & Cntr).Value
End If
End If
Next
End Sub



[ This Message was edited by: Mikeyboy on 2002-04-27 13:15 ]
mikeyboy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:25 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes