Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 05-27-2014, 10:12 PM
macropod's Avatar
macropod macropod is offline Macro help Windows 7 32bit Macro help Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim lRow As Long, lCol As Long, i As Long, j As Long
Dim xlWkBk As Workbook, xlSht As Worksheet, StrSht As String
Set xlWkBk = ThisWorkbook: StrSht = ""
Set xlSht = xlWkBk.Worksheets("Sheet1")
With xlWkBk.Worksheets("Sheet1").UsedRange
  lRow = .Range("A" & .Cells.SpecialCells(xlCellTypeLastCell).Row).End(xlUp).Row
  lCol = .Cells.SpecialCells(xlCellTypeLastCell).Column
  For i = 1 To lRow
    Select Case .Cells(i, 1).Text
      Case "CY"
        StrSht = "CY": j = 0
        Set xlSht = xlWkBk.Sheets.Add(After:=xlSht)
        xlSht.Name = StrSht
      Case "DL"
        StrSht = "DL": j = 0
        Set xlSht = xlWkBk.Sheets.Add(After:=xlSht)
        xlSht.Name = StrSht
      Case "EU"
        StrSht = "EU": j = 0
        Set xlSht = xlWkBk.Sheets.Add(After:=xlSht)
        xlSht.Name = StrSht
    End Select
    If StrSht <> "" Then
      j = j + 1
      .Range(.Cells(i, 1), .Cells(i, lCol)).Copy
      xlSht.Paste Destination:=xlSht.Cells(j, 1)
    End If
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft