Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code: Copying rows from multiple sheets

Status
Not open for further replies.

Nctukek

Vendor
Oct 11, 2012
1
US
Hello,
I'm trying to use VBA to copy rows that satisfy a certain 'If-Then' statement from multiple sheets in Excel onto one sheet. All of the sheets have the same columns and each set is one month in a year. I've gotten the code to work for one sheet but I need the next month's rows to be copied on to the final sheet relative to where the previous month's ended. The first month I've copied is 'April' and I am copying all of them onto a sheet titled 'Change Summary 1'. Here is my code thus far:

Option Explicit
Sub Module1()
Dim i
Dim e
Dim k
Dim l
Dim m
Dim n
Dim o
Dim p
Dim s
Dim t
Dim u
Dim v
Dim w
Set i = Sheets("April")
Set k = Sheets("May")
Set l = Sheets("June")
Set m = Sheets("July")
Set n = Sheets("Aug")
Set o = Sheets("Sep")
Set p = Sheets("Oct")
Set s = Sheets("Nov")
Set t = Sheets("Dec")
Set u = Sheets("Jan")
Set v = Sheets("Feb")
Set w = Sheets("Mar")
Set e = Sheets("Change Summary 1")
Dim d
Dim j
Dim a
d = 5
j = 5
a=5+d
Do Until IsEmpty(i.Range("I" & j))

If i.Range("I" & j) = "Yes" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
If k.Range("I" & j) = "Yes" Then
a = a + 1
e.Rows(a).Value = k.Rows(j).Value
End If
End If
j = j + 1
Loop


End Sub

My biggest problem is making the next month show up relative to the month before it on the 'Change Summary 1' sheet. Any suggestions are appreciated, although please note that I am VERY new to VBA and don't quite fully understand it yet. Thank you in advance!

 
hi,

Please post VBA in forum707.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top