Copy/Paste in value within 'With/Next'

Matador_24

Board Regular
Joined
Dec 1, 2011
Messages
205
Hello,

I am building a macro, I am in a section with a With / Next Loop.
I need to copy/paste in every loop the content of cell B3 because there is currently a vlookup formula where I bring data to excel. Thus, I need to copy/paste in value that cell.

Could you please help me with the code?

I tried macro recording:


Code:
Windows("LH Reporting tool v1.6 - Stonehenge.xlsm").Activate    Range("B3").Select   Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False    
Application.CutCopyMode = False



But that gives me an error in the code I think because I am in a loop,

Thanks in advance!

Luis
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You don't need to copy and paste. Try it this way.

Code:
With Windows("LH Reporting tool v1.6 - Stonehenge.xlsm").Range("B3")
     .Value = .Value
End With
 
Upvote 0
Hello,

Actually, how can I add it to my below code?

Code:
Worksheets("Balance Sheet").Activate
r = 3
With Worksheets("sheet1").PivotTables(1)
        'Cells(r, 1) = .PivotFields("Year").Name
        For x = 1 To .PivotFields("Top Level Object Reference").PivotItems.Count
            DealNumber = .PivotFields(3).PivotItems(x).Visible
            If DealNumber = -1 Then
                DealNameActive = "=VLOOKUP(B4,'V:\Real Estate\Portfolio Management\Daniela\Working files\[Chart of Account.xlsx]Partner Investments'!$B$1:$F$10000,5,FALSE)"

I prefer to avoid using the name of the file as it changes depending on the investment. How would you add it above? Please note that there is a With, and a For already,

Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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