Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,277 of 10,840    |
|    StoneWare to All    |
|    Re: Using "IF" Statement    |
|    11 Mar 05 21:08:47    |
   
   From: HejMedDig@NoSpam.Net   
      
   "Scott Beavers" skrev i en meddelelse   
   news:p-KdnRsPr_34d6zfRVn-uw@cmspan.net...   
   > I'm trying to create a form in Excel to sort from the form and take the   
   > data   
   > to another worksheet.   
   > I am very new to this and any help would be appreciated.   
   >   
   > I have a value in a cell that will direct what sheet I want the cells   
   > copied   
   > to, so I thought I could use an If statement but have been unable to right   
   > the code properly, ie...   
   >   
   > If "f2" = 1 Then   
   > Sheets("XX1").Select   
   > Range("A2").Select   
   > ActiveSheet.Paste   
   >   
   > Else   
   > If "f2" = 2 Then   
   > Sheets("XX2").Select   
   > Range("A2").Select   
   > ActiveSheet.Paste   
   >   
   > Else   
   > If "f2" = 3 Then   
   > Sheets("XX3").Select   
   > Range("A2").Select   
   > ActiveSheet.Paste   
   >   
   > Else   
   > If "f2" = 4 Then   
   > Sheets("XX4").Select   
   > Range("A2").Select   
   > ActiveSheet.Paste   
   >   
   > Else   
   > If "f2" = 5 Then   
   > Sheets("XX5").Select   
   > Range("A2").Select   
   > ActiveSheet.Paste   
   >   
   > End If   
   >   
   >   
      
   A select case is better in this case   
      
   Select case "f2"   
    case 1   
    Sheets("XX1").Select   
    Range("A2").Select   
    ActiveSheet.Paste   
    case 2   
    Sheets("XX2").Select   
    Range("A2").Select   
    ActiveSheet.Paste   
    case 3   
    Sheets("XX3").Select   
    Range("A2").Select   
    ActiveSheet.Paste   
    case 4   
    Sheets("XX4").Select   
    Range("A2").Select   
    ActiveSheet.Paste   
    case 5   
    Sheets("XX5").Select   
    Range("A2").Select   
    ActiveSheet.Paste   
   End select   
      
      
      
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca