Thursday, July 21, 2011

How to get and put cell values to excel sheet using macros?

Simple macros can be great time-savers. Here is a simple macro to create a table by fetching values from different places (but in a definite order) of a spreadsheet.
=========================================================================

Count = 0
    For i = 1 To 15
     
           date_1 = ActiveSheet.Cells(1, 8 + Count).Value
           dilbit = ActiveSheet.Cells(4, 6 + Count).Value
           lago = ActiveSheet.Cells(17, 6 + Count).Value
           percentag = ActiveSheet.Cells(29, 10 + Count).Value
         
   
           ActiveSheet.Cells(i + 36, 1).Value = date_1
           ActiveSheet.Cells(i + 36, 2).Value = dilbit
           ActiveSheet.Cells(i + 36, 3).Value = lago
           ActiveSheet.Cells(i + 36, 4).Value = percentag
         
        Count = Count + 7
           
    Next
=========================================================================

No comments: