VBA Copy from WB to WB, decide which sheet to copy to.

jakobt

Active Member
Joined
May 31, 2010
Messages
337
Have a workbook called WB_A (Active workbook) and a workbook: WB_B
Want to copy sheet1 (A1:currentregion) from WB_B to WB_A.

The sheet should be inserted:
If one of the sheets in WB_A is called TB* (*meaning any other character) it should be overwritten, and copied in from cell A1.

If there is no sheet called TB* then a new sheet should be inserted named "TB.

(This should be with a VBA code, as it is part of a bigger VBA code)
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
try
workbooks("wb_A.xlsx").worksheets("sheet1").usedrange.copy
For a = 1 to sheets.count
if left(sheets(a).name,2) = "TB" then
sheets(a).Range(A1").pastespecial
end if
next a
msgbox "complete"
Ravi shankar
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

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