Violet2802
New Member
- Joined
- Jan 5, 2017
- Messages
- 2
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993}span.s1 {color: #011993}span.s2 {color: #000000}</style>Hi,
I am trying to use VBA to copy rows from the master spreadsheet into the corresponding tabs (EMAS/EEAST/YAS/SWAST/WAST) depending on the condition in a specific column (D). The first part of my code works and copies data that includes the term "EMAS" into the appropriate sheet. However, the additional 4 sheets will not populate with their specific terms. What am I doing wrong with the code? I am very new to this so it's hopefully very basic. I have arbitrarily given the worksheets identifying letters, I don't know if that's okay. It seems to have worked for the EMAS tab, but no others!
Sub Button1_Click()
Set i = Sheets("MASTER")
Set e = Sheets("EMAS")
Set b = Sheets("EEAST")
Set c = Sheets("YAS")
Set f = Sheets("SWAST")
Set g = Sheets("WAST")
Dim d
Dim j
d = 1
j = 2
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "EMAS" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "EEAST" Then
d = d + 1
b.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "YAS" Then
d = d + 1
c.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "SWAST" Then
d = d + 1
f.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "WAST" Then
d = d + 1
g.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
End Sub
Many Thanks!
I am trying to use VBA to copy rows from the master spreadsheet into the corresponding tabs (EMAS/EEAST/YAS/SWAST/WAST) depending on the condition in a specific column (D). The first part of my code works and copies data that includes the term "EMAS" into the appropriate sheet. However, the additional 4 sheets will not populate with their specific terms. What am I doing wrong with the code? I am very new to this so it's hopefully very basic. I have arbitrarily given the worksheets identifying letters, I don't know if that's okay. It seems to have worked for the EMAS tab, but no others!
Sub Button1_Click()
Set i = Sheets("MASTER")
Set e = Sheets("EMAS")
Set b = Sheets("EEAST")
Set c = Sheets("YAS")
Set f = Sheets("SWAST")
Set g = Sheets("WAST")
Dim d
Dim j
d = 1
j = 2
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "EMAS" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "EEAST" Then
d = d + 1
b.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "YAS" Then
d = d + 1
c.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "SWAST" Then
d = d + 1
f.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
Do Until IsEmpty(i.Range("D" & j))
If i.Range("D" & j) = "WAST" Then
d = d + 1
g.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
End Sub
Many Thanks!
