Wednesday, July 6, 2011

VBA code for copying range of cells in excel

I helped someone make a copy of some cells in an excel spreadsheet using VBA. Thy were adding a recipe to another worksheet.

'move to the AddRecipes tab
Sheets("AddRecipes").Select
'select the range of recipe ingredients and then copy the selection.
Range("C11:C30").Select
Selection.Copy
'select the dessert sheet
Sheets("DessertIngredients").Select
'select the range and then paste there using the dynamic variables in the for loop
Range(Cells(Row1 + 1, Column1), Cells(Row1 + 21, Column1)).Select
ActiveSheet.Paste

1 comment:

DataDiary.com said...

it's good for all and very impressive if we use in our project...