Set Range Name

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have code that I will admit someone helped me with by writting almost all of it

Its running down a row and when it equals Yes it copys a section (11 row) on another tabs
and pastes it below it in the next availale row. It does this perfectly. What I would like to do is when it hits a Yes on the tab titled "WBS" copy the value in the next cell over and then paste it in the new selection thats being copied down in the second cell over.

'Pull over WBS numbers that have BOE sheets
Dim wsDst As Worksheet
Dim wsYesNo As Worksheet
Dim rngDst As Range
Dim rngSrc As Range
Dim clYesNo As Range
Set wsDst = Worksheets("BOE Summary")
'
Set rngDst = wsDst.Range("A" & Rows.Count).End(xlUp).Offset(1)
'
Set rngSrc = wsDst.Range("12:22")
'
Set wsYesNo = Worksheets("WBS")
For Each clYesNo In wsYesNo.Range("B10:B200").Cells
If clYesNo.Value = "Yes" Then
rngSrc.Copy rngDst

HERES WHERE I WANT IT TO COPY ONE CELL OVER FROM WHEN VALUE="YES" AN DCOPY IT INTO COLUMN B OF THE rngDst. First ROW

Set rngDst = rngDst.Offset(11)
End If
Next clYesNo
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
It may be that you want to change this
Code:
Set rngDst = wsDst.Range("A" & Rows.Count).End(xlUp).Offset(1)
for this
Code:
Set rngDst = wsDst.Range("A" & Rows.Count).End(xlUp).Offset(1,1)
 
Upvote 0
Code:
Sub Macro2()
    'Pull over WBS numbers that have BOE sheets
    Dim wsDst As Worksheet
    Dim wsYesNo As Worksheet
    Dim rngDst As Range
    Dim rngSrc As Range
    Dim clYesNo As Range
    
    Set wsDst = Worksheets("BOE Summary")
    '
    Set rngDst = wsDst.Range("A" & Rows.Count).End(xlUp).Offset(1)
    '
    Set rngSrc = wsDst.Range("12:22")
    '
    Set wsYesNo = Worksheets("WBS")
    For Each clYesNo In wsYesNo.Range("B10:B200").Cells
    If clYesNo.Value = "Yes" Then
    rngSrc.Copy rngDst
    
    [COLOR="Green"]'HERES WHERE I WANT IT TO COPY ONE CELL OVER FROM WHEN VALUE="YES" AN DCOPY IT INTO COLUMN B OF THE rngDst. First ROW[/COLOR]
    [COLOR="Red"]clYesNo.Offset(, 1).Copy Destination:=rngDst(1).Offset(, 1)[/COLOR]
    
    Set rngDst = rngDst.Offset(11)
    End If
    Next clYesNo
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top