Can't copy sheets from one file to another

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Can't copy sheets from one file to another



I'm new here, and was hoping to get some help with my code.



So i got 2 Excel files. test1 and test2. Im trying to take 5 rows and 5 columns from one to the other. But it gives me a weird error.. Heres the code:



'rows
For r As Integer = 1 To 5


'columns
For c As Integer = 1 To 5

'copy the value of the cell
WB2.Sheets(2).Cells(r, c).Value = WB1.Sheets(1).Cells(r, c).Value

'or text:
'WB2.Sheets(2).Cells(r, c).Text = WB1.Sheets(1).Cells(r, c).Text

Next

Next



the loop gives me an error "HRESULT: 0x8002000B (DISP_E_BADINDEX))





Where exactly do you get this error? maybe a screenshot of what you're trying to do would help. I get the impression this is not a VBA error and that your question is missing some critical infomation.
– ashleedawg
1 min ago











By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty