Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Opening new worksheets based on entries

Glad you got it going. And don't mind me; I am not a butt all the time. I
was just playing with your a little <g

--
Regards,
Tom Ogilvy


"RomanR" wrote:

It's my fault Tom, don't worry, it is obvious that it has to change. I
figured I had to use the name of my excel file, which I tried, except I
entered the file name (dns.txt) instead of just the sheet name (dns).
That's where I got confused and posted back here. It works wonders now,
thanks very much again for the help, I appreciate it.

Regards,

Roman


Tom Ogilvy wrote:
I guess I should have said to change Data to reflect the name of the sheet
that contains your data, but I foolishly thought that would be obvious. My
Bad

Let me try again:

The following code is tested and worked with the data you showed and the
assumptions I previously stated. Make sure you change the sheet reference
(worksheets("Data")) to refer to the sheet that contains your data. I placed
your sample data on a sheet named DATA.

Sub copyIP()
Dim sh As Worksheet, Startrow As Long
Dim lastrow As Long, v1, v, i As Long

' change the next line to reflect the sheet that contains
' your data. for example, if your data was on a sheet
' with the name sheet1, the next line would actually be
' Set sh = Worksheets("Sheet1")
' I used the name Data for illustration

Set sh = Worksheets("Data") '<=== CHANGE

Startrow = 1
lastrow = sh.Cells(Rows.Count, 1).End(xlUp).Row
ReDim v1(0 To 3)
v1(2) = ""
i = 1
For i = 1 To lastrow
v = Split(sh.Cells(i, 1), ".")
If v(2) < v1(2) And i < 1 Then
Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = v1(2)
sh.Range(sh.Rows(Startrow), sh.Rows(i - 1)).Copy _
ActiveSheet.Range("A1")
Startrow = i
End If
v1 = v
Next i
Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = v1(2)
sh.Range(sh.Rows(Startrow), sh.Rows(lastrow)).Copy _
ActiveSheet.Range("A1")
End Sub


--
Regards,
Tom Ogilvy


"RomanR" wrote:

Thanks Tom. This line returns a run-time "subscript out of range" error
however:

Set sh = Worksheets("Data")


Thanks

Roman




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can cell entries be based on word entries in another cell ? lifewings Excel Worksheet Functions 1 June 24th 08 05:45 PM
Sum log entries based on date [email protected] Excel Discussion (Misc queries) 3 February 27th 07 04:35 PM
Sum log entries based on date [email protected] Excel Discussion (Misc queries) 2 February 27th 07 03:42 AM
advanced filtering based on entries ABOVE those I wish to keep Cale Excel Discussion (Misc queries) 0 August 1st 06 09:11 PM
Duplicate entries in multiple worksheets m96 Excel Worksheet Functions 0 July 4th 06 12:40 PM


All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"