Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using dates in macros

Hello, I have just started in VBA and I would like to do the following:

- go through an array and look for some entries for which the dates are
in next month
- put these entries in a new sheet

Can somebody help please?

Thanx,

Zack.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Using dates in macros

Hi,
You probably need a routine such as this but with sheet
names and cell referneces that reflect your particular
situation:

mth = Month(Date) + 1

For a = 1 To 30

Worksheets("Sheet2").Select

If Month(Cells(a, 1)) = mth Then

With Worksheets("Sheet2")
..Range(.Cells(a, 1), .Cells(a, 5)).Copy
End With

Worksheets("sheet1").Select

ActiveSheet.Cells(a, 1).PasteSpecial

Else


End If

Next a

End Sub

Best of luck
DavidC
-----Original Message-----
Hello, I have just started in VBA and I would like to do

the following:

- go through an array and look for some entries for which

the dates are
in next month
- put these entries in a new sheet

Can somebody help please?

Thanx,

Zack.


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using dates in macros

This is the basic code which you will need to adapt as required :-


Code
-------------------
Sub test()
Dim NextMonth As Integer
Dim FromRow As Long
Dim ToRow As Long
'--------------------
NextMonth = Month(Date) + 1
ToRow = 1
'--
For FromRow = 1 To 1000
If Month(ActiveSheet.Cells(FromRow, 1).Value) = NextMonth Then
Worksheets("Sheet1").Cells(ToRow, 1).Value = _
ActiveSheet.Cells(FromRow, 1).Value
ToRow = ToRow + 1
End If
Next
MsgBox ("Done.")
End Sub

-------------------


--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM
List the Macros that can be executed from Tools-Macros Rob Bovey Excel Programming 1 July 10th 03 05:34 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"