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,296 of 10,840    |
|    Ade to Scott Beavers    |
|    Re: Using "IF" Statement    |
|    15 Mar 05 14:50:00    |
   
   From: adrian.birkett@ic24.net   
      
   "Scott Beavers" wrote in message   
   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   
   >   
   >   
   >   
      
   Hi,   
      
   Assuming that you have the workbook (WB) open and what you want is on the   
   sheet named "Sheet1"...   
      
   CellValue = WB.WorkSheets("Sheet1").Cells("F2").Value   
      
   OpenSheet = "XX" & Trim(CellValue)   
   Sheets(OpenSheet).Select   
   Range("A2").Select   
   ActiveSheet.Paste   
      
   The above might not be wholly accurate bit it's a whole lot shorter than   
   your example.   
      
   Ade   
      
   --- 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