0
Hello! I have a VBA code in the format below. It takes all the information from column B and sends it to another tab, whenever the value of B1 is changed (only does not create another, if you already have one), renaming this new tab created with the value described in B1. However, I want to put in the new tabs that are created, also the column A as they are described in the original spreadsheet (which I called Plan3) (can be the whole column or A1:A11). How could I proceed?
Dim i: i = 1
Dim B1_val As String
B1_val = ThisWorkbook.Worksheets("Plan3").Range("B1").Value
myValue = ThisWorkbook.Worksheets("Plan3").Range("B" & i).Value
Dim ws As Worksheet
If Not (doesSheetExist(B1_val)) Then
Set ws = ThisWorkbook.Worksheets.Add(Type:=xlWorksheet)
With ws
.Name = B1_val
End With
While myValue <> ""
Set cellv = ThisWorkbook.Worksheets(B1_val).Range("B" & i)
cellv.Value = myValue
i = i + 1
myValue = ThisWorkbook.Worksheets("Plan3").Range("B" & i).Value
Wend
End If
End Sub
Public Function doesSheetExist(strSName As String) As Boolean
Set wb = ActiveWorkbook
Dim obj As Object
On Error GoTo ErrorHandler
Set obj = wb.Sheets(strSName)
doesSheetExist = True
Exit Function
ErrorHandler:
doesSheetExist = False
End Function