View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
tkraju via OfficeKB.com tkraju via OfficeKB.com is offline
external usenet poster
 
Posts: 109
Default Extract data from one range and place in the same sheet

Thank You Per Jessen, It gave me perfect results.
I am curious to learn ,what activity happens line by line when this sub runs?
Can you please explain me?I am just new to vba.

Per Jessen wrote:
Hi

Try this:

Sub extractData()
Dim sName As String
Dim dDate As Date
Dim Ammount As Double
Dim LastRow As Long
Dim off As Long

LastRow = Range("A" & Rows.Count).End(xlUp).Row
sName = Range("D1").Value
dDate = Range("E1").Value
For r = 2 To LastRow
If Format(Cells(r, 2), "mm-yy") = Format(dDate, "mm-yy") Then
If Cells(r, 1).Value = sName Then
Cells(r, 2).Resize(1, 2).Copy Cells(2 + off, "D")
off = off + 1
End If
End If
Next
End Sub

Regards,
Per

Hi Simon,
Col A to Col c ,the database is updated daily thus the sales figures in Col c

[quoted text clipped - 17 lines]
--
Message posted viahttp://www.officekb.com


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1