+ Reply to Thread
Results 1 to 4 of 4

Add sheet problem....

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2008
    Posts
    3

    Looping(Help needed urgently)

    I would like to add a new sheet and then run the if-else statement for four times,means the if-else statement will loop for four time,then the fifth times and so on(if-else will run four time in a sheet).....Means the if-else statement loop for four time and then will add new sheet for fifth times to eight times and so on....May I know how could I do so????Help is needed urgently.....

    'row 23 so on and column 1
    For r = 23 To 24022
    
     
    If Not (Cells(r, 1).Value = "") Then
            'add worksheet
            With ActiveWorkbook.Sheets
             
            .Add after:=Worksheets(Worksheets.count)
    
    
    With ActiveSheet
               ‘row 23 so on and column 2
                For s = 23 To 24022 Step 10
                 If Not (Cells(s, 2).Value = "" Then
                
                 If Cells(s, 2).Value = "Activity" Then
                    ActiveSheet.Shapes.AddShape(msoShapeRectangle, 191.25, 230.25, 
                    144#,87.75). _
                    Select
                    Selection.Characters.Text = Join(Evaluate("transpose(" & .Cells(r, 
                    1).Resize(10).Address & ")"), vbLf)
                 ElseIf Cells(s, 2).Value = "Optional Activity" Then
                     ActiveSheet.Shapes.AddShape(msoShapeRectangle, 191.25, 230.25, 
                     144#, 87.75)._
                     Select
                     Selection.Characters.Text = Join(Evaluate("transpose("
                     & .Cells(r,1).Resize(10).Address & ")"), vbLf)
                  ElseIf Cells(s, 2).Value = "Decision" Then
                    ActiveSheet.Shapes.AddShape(msoShapeFlowchartDecision, 191.25, 
                     230.25, 144#, 87.75). _
                     Select
                     Selection.Characters.Text = Join(Evaluate("transpose(" & .Cells(r, 
                     1).Resize(10).Address & ")"), vbLf)
                   End If
                      
                     r = r + 10
                    
                      End If
              
              Next s
          End with

  2. #2
    Registered User
    Join Date
    05-15-2008
    Posts
    3

    Add sheet problem....

    I would like to add a new sheet and then run the if-else statement for four times,means the if-else statement will loop for four time,then the fifth times and so on(if-else will run four time in a sheet).....Means the if-else statement loop for four time and then will add new sheet for fifth times and so on....May I know how could I do so????Help is needed urgently.....


    'row 23 so on and column 1
    For r = 23 To 24022
    
     
    If Not (Cells(r, 1).Value = "") Then
            'add worksheet
            With ActiveWorkbook.Sheets
             
            .Add after:=Worksheets(Worksheets.count)
    
    
    With ActiveSheet
               ‘row 23 so on and column 2
                For s = 23 To 24022 Step 10
                 If Not (Cells(s, 2).Value = "" Then
                
                 If Cells(s, 2).Value = "Activity" Then
                    ActiveSheet.Shapes.AddShape(msoShapeRectangle, 191.25, 230.25, 
                    144#,87.75). _
                    Select
                    Selection.Characters.Text = Join(Evaluate("transpose(" & .Cells(r, 
                    1).Resize(10).Address & ")"), vbLf)
                 ElseIf Cells(s, 2).Value = "Optional Activity" Then
                     ActiveSheet.Shapes.AddShape(msoShapeRectangle, 191.25, 230.25, 
                     144#, 87.75)._
                     Select
                     Selection.Characters.Text = Join(Evaluate("transpose("
                     & .Cells(r,1).Resize(10).Address & ")"), vbLf)
                  ElseIf Cells(s, 2).Value = "Decision" Then
                    ActiveSheet.Shapes.AddShape(msoShapeFlowchartDecision, 191.25, 
                     230.25, 144#, 87.75). _
                     Select
                     Selection.Characters.Text = Join(Evaluate("transpose(" & .Cells(r, 
                     1).Resize(10).Address & ")"), vbLf)
                   End If
                      
                     r = r + 10
                    
                      End If
              
              Next s
          End with

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    daniel50096230,

    Welcome to the forum. Please read the forum rules below. Your duplicate posts have being merged and you need to add the link to the other excel forum

    VBA Noob
    Last edited by VBA Noob; 06-14-2008 at 02:31 AM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you add a new sheet it's empty.The new sheet is the active sheet so how can a loop find any values?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1