Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Split cells VBA

Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
..Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be great!

Thanks
Diddy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Split cells VBA

What is the problem, the plethora of workbooks, the desire to process
multiple sheets, or what?

--

HTH

Bob

"Diddy" wrote in message
...
Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
.Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be
great!

Thanks
Diddy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Split cells VBA

Hi Bob,

Being truthful, the basic problem is lack of understanding of objects etc so
when I had anything out of the ordinary (i.e. the different wkbks had sheets
which had names specific to the wkbk) I didn't know what to do :-(

Cheers
Diddy (learning very slowly!)



"Bob Phillips" wrote:

What is the problem, the plethora of workbooks, the desire to process
multiple sheets, or what?

--

HTH

Bob

"Diddy" wrote in message
...
Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
.Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be
great!

Thanks
Diddy



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Split cells VBA

Hi,

Activesheet shout work in a single sheet workbook so you could try

With ActiveSheet

This should work also

With Sheet1.

Note we've now dropped the quotes because were not using a sheet name
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Diddy" wrote:

Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
.Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be great!

Thanks
Diddy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Split cells VBA

Hi Mike,

Both worked :-)

Cheers
Diddy

"Mike H" wrote:

Hi,

Activesheet shout work in a single sheet workbook so you could try

With ActiveSheet

This should work also

With Sheet1.

Note we've now dropped the quotes because were not using a sheet name
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Diddy" wrote:

Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
.Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be great!

Thanks
Diddy



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Split cells VBA

Hi Diddy,

Try one of theese:

With Worksheets(1)

or

With ActiveSheet

Regards,
Per


"Diddy" skrev i meddelelsen
...
Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
.Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be
great!

Thanks
Diddy


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Split cells VBA

Thank you Per,

Cheers
Diddy


"Per Jessen" wrote:

Hi Diddy,

Try one of theese:

With Worksheets(1)

or

With ActiveSheet

Regards,
Per


"Diddy" skrev i meddelelsen
...
Hi everyone,

I've been using the following (kindly supplied by Rick Rothstein) to split
address items.

Sub SplitCells()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Sections() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 2 To LastRow
Sections = Split(.Cells(X, "A").Value, "/")
For Z = 0 To UBound(Sections)
.Cells(X, Z + 2).Value = Sections(Z)
Next
Next
End With
End Sub

I now have lots of single sheet wkbks which have named sheets. I've tried
taking the " " out from the With Worksheets("Sheet1") and also calling it
Activesheet getting very mixed up :-(

If anyone can help (possibly explain what's foxing me) that would be
great!

Thanks
Diddy


.

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
Split Cells slfalconi Excel Discussion (Misc queries) 2 January 20th 10 03:59 AM
How to Split the contents of cells across multiple cells anna New Users to Excel 5 May 29th 08 02:47 PM
Split cells Elaine New Users to Excel 3 April 21st 08 05:16 PM
Split Cells? [email protected] Excel Programming 1 December 12th 07 06:11 AM
Split Cells Stuart[_3_] Excel Programming 2 April 17th 07 08:46 PM


All times are GMT +1. The time now is 04:42 AM.

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"