ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Help on VBA Code to populate multiple sheets (https://www.excelbanter.com/excel-discussion-misc-queries/173015-help-vba-code-populate-multiple-sheets.html)

[email protected]

Help on VBA Code to populate multiple sheets
 
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 . Thanks.


carlo

Help on VBA Code to populate multiple sheets
 
On Jan 15, 12:51*pm, wrote:
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 . 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


All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com