Hey folks
Got stuck in this one and hope someone can help me out.
I create a workbook by vba and my problem is simply that I cannot change the new workbook to be the activeworkbook where i can select cells and so fourth. I can insert values in cells in the new workbook, but as I need to copy cells from the original workbook to the new one and further manipulate the data, I need to be able to select cells in the new wb. Thanks in advance for your help! Code is following:
Sub Test_Excel()
Dim MyXL As Object 'Excel Application Object
Dim XL_File As String
Dim SheetName As String
Dim curWorkbook As Workbook
Set curWorkbook = ActiveWorkbook
SheetName = "New Sheet Name"
'Create the Excel Application Object.
Set MyXL = CreateObject("Excel.Application")
'Create new Excel Workbook
MyXL.Workbooks.Add
MyXL.Worksheets(1).Name = SheetName
MyXL.Application.Visible = True
MyXL.Worksheets(SheetName).Range("A1").Value = "This is a test!!!!"
ActiveWorkbook.Worksheets(1).Range("b1").Select 'this line and the one below is just to test which is the active workbook..
MsgBox ActiveWorkbook.Name
Set MyXL = Nothing
End Sub
Bookmarks