Help on VBA Code to populate multiple sheets

  • Thread starter Thread starter TLIUALL
  • Start date Start date
T

TLIUALL

I need to write VBA codes to handle the following situation.

There are two sheets S1(Summary Info), and S2(Detail for creating new
sheets)

On S1, I summarizes inf as follow

NewSheetName CellRangeFromS2
A A2.K12
B A13.K19
C A20.K35

So, how can I create additional sheets A, B, C and paste all info
referred above in Cell A1.

I had diffcult time to do the loop through. Any help is greatly
appreciated. My email is (e-mail address removed). Thanks.
 
I need to write VBA codes to handle the following situation.

There are two sheets S1(Summary Info), and S2(Detail for creating new
sheets)

On S1, I summarizes inf as follow

NewSheetName   CellRangeFromS2
A                            A2.K12
B                            A13.K19
C                            A20.K35

So, how can I create additional sheets A, B, C and paste all info
referred above in Cell A1.

I had diffcult time to do the loop through. Any help is greatly
appreciated. My email is (e-mail address removed). Thanks.

Hope i understood you correctly

Sub create()

Dim S1 As Worksheet
Dim S2 As Worksheet
Dim newS As Worksheet
Dim tmpStr As String

Set S1 = Worksheets("S1")
Set S2 = Worksheets("S2")

For i = 2 To S1.Cells(65536, 1).End(xlUp).Row
Set newS = Worksheets.Add(After:=Worksheets(Sheets.Count))
newS.Name = S1.Cells(i, 1)
tmpStr = S1.Cells(i, 2).Value
If InStr(tmpStr, ".") > 0 Then
tmpStr = Replace(tmpStr, ".", ":")
S2.Range(tmpStr).Copy newS.Range("A1")
End If
Next i

End Sub

hth
Carlo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top