Copy Value from new Workbook to existing Workbook
Closed
classermild
Posts
1
Registration date
Friday September 14, 2018
Status
Member
Last seen
September 14, 2018
-
Sep 14, 2018 at 03:14 AM
Blocked Profile - Sep 14, 2018 at 05:11 PM
Blocked Profile - Sep 14, 2018 at 05:11 PM
Related:
- Copy the salaries worksheet to a new workbook
- Copy worksheet to another workbook vba - Guide
- Transfer data from one excel worksheet to another automatically - Guide
- Vba add worksheet - Guide
- Insert a new sheet at the end of the tab names and paste the range names starting in cell a1. autofit columns a:b and name the worksheet as named ranges. ✓ - Excel Forum
- Excel vba copy worksheet to another workbook without opening ✓ - Excel Forum
1 response
Yes, this is possible.
Below are some code examples. Cut and paste what you need and make your own routine.
Below are some code examples. Cut and paste what you need and make your own routine.
Function sheetexist(whatsheet)
On Error GoTo NotExists
ThisWorkbook.Worksheets(whatsheet).Select
sheetexist = True
Exit Function
NotExists:
sheetexist = False
End Function
Function testsheet(whichsheet, rowNum)
nret = sheetexist(whichsheet)
If nret = False Then makesheet (whichsheet)
nret = copyrowX(whichsheet, rowNum)
End Function
Sub makesheet(whatsheet)
On Error GoTo ExitSub
With ThisWorkbook
.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = whatsheet
End With
ExitSub:
End Sub
Function copyrowX(towhatsheet, whatrow)
ThisWorkbook.Worksheets("Sheet1").Select
ThisWorkbook.Worksheets("Sheet1").Range("A" & whatrow).EntireRow.Select
Selection.Copy
ThisWorkbook.Worksheets(towhatsheet).Select
cellcount = Cells(ThisWorkbook.Worksheets(towhatsheet).Rows.Count, 1).End(xlUp).Row
ThisWorkbook.Worksheets(towhatsheet).Range("A" & cellcount).EntireRow.Select
Selection.Insert
End Function
Sub ReadSheet()
cellcount = Cells(ThisWorkbook.Worksheets("Sheet1").Rows.Count, 1).End(xlUp).Row
For RowCount = 1 To cellcount
cellvalue = ThisWorkbook.Worksheets("Sheet1").Range("A" & RowCount).Value
nret = testsheet(cellvalue, RowCount)
ThisWorkbook.Worksheets("Sheet1").Select
Next
End Sub