Forum Discussion

JMarshall325's avatar
JMarshall325
Copper Contributor
Aug 11, 2020

Auto fill columns across an Excel table

Good afternoon,
I need to fill in the Document ID columns in a table so that each Tag Term has a Document ID associated with it. The Document IDs should only fill in where there is a corresponding Term Tag in the column to the right of it. The table has 2000 paired columns, so can someone tell me how I can do that automatically - like with a macro for example? The Starting Table sample is what the table looks like now. The Finished Table sample is how I want the table to be filled in.
 
STARTING TABLE SAMPLE
 
Document IDTerm tagDocument IDTerm tagDocument IDTerm tag
145436 145441 145461 
 National Criminal Justice Reference Service (NCJRS) Students Fellowship Programs
 Grants.gov (website) Grants.gov (website)  
 Technical assistance (TA) Fellowship Programs  
 Forensic sciences    
 
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FINISHED TABLE SAMPLE
Document IDTerm tagDocument IDTerm tagDocument IDTerm tag
145436 145441 145461 
145436National Criminal Justice Reference Service (NCJRS)145441Students145461Fellowship Programs
145436Grants.gov (website)145441Grants.gov (website)  
145436Technical assistance (TA)145441Fellowship Programs  
145436Forensic sciences    
 
 
Thanks in advance.
Regards,
JMarshall
 

 

6 Replies

  • mathetes's avatar
    mathetes
    Silver Contributor

    JMarshall325 

     

    The formula that you see in the formula bar here will do it--just copy down, to however many rows the max would be, and then copy/paste those cells to the alternating columns the rest of the way across your 2000 columns. That's how I did it in the file I created to demonstrate.

     

    I figure a half-second for each copy/paste and that would take just over 8 minutes. It would probably take longer to write and execute a macro.

     

    • JMarshall325's avatar
      JMarshall325
      Copper Contributor

      mathetes 

      Thanks for your speedy reply. One more question - how would you repeat the formula to repeat the action.

      Would it be like so the following?

       

               =IF(B3<>"",A2,""),(D3<>"",C2,""),(F3<>"",E2,"")    

       

      Regards,

      JMarshall

      • mathetes's avatar
        mathetes
        Silver Contributor

        JMarshall325 

         

        Did you try copy and paste?  I'm going to make an assumption here, based on the question: you seem to be very much a beginner with Excel, and maybe even not confident with computers. So without wanting to be too basic, I'm going to spell out steps.

         

        First of all, you can copy and paste from the initial cell (ie., copy A3) and then highlight the cells below it, as far as you want to go, and do a "paste." The formula will automatically adjust the references because I used relative, not absolute, references.

         

        And the same is true when you copy to cell C3 and the cells below that. You do not need to re-write the formula. Copy it and paste it.

         

        And even better, you can use keyboard short-cuts CTRL+C to copy, CTRL+V to paste. Or, if you're in a Mac (as I am) Command+C to copy, Command+V to paste. And you can copy all of the range A3:A10 or whatever to C3:C10...   Those keyboard short-cuts are what I was assuming would be used when I said it would go quickly.

         

        Postscript: I apologize for not including the spreadsheet itself. I didn't even save it because I thought those copy and paste steps were so basic that you'd know how to proceed. I could re-create it if you need that level of assistance.

Resources