![]() |
Using a code n times
I´m trying to programm with VBA in Excel.
I have in a sheet the code farmers. I also have the sheet Trees, the sheet WaterQuality , the sheet WaterQuantity and the sheet Biodiversity, etc. I need to copy the code Farmers into those sheets. Each farmer will be associated with every range in the code trees, code waterQuality, etc. I want to avoid copying the Farmer code every time I need it Does somebody may showed me how to copy the code farmer in the codes I describe as example? Many thanks in advance CodFarmers Range("A1").Select Range("A2").FormulaR1C1 = "201" Range("A2").Select Range("A3").FormulaR1C1 = "202" Range("A3").Select Range("A4").FormulaR1C1 = "203" Range("A4").Select Range("A5").FormulaR1C1 = "204" Range("A5").Select Range("A6").FormulaR1C1 = "205" Range("A6").Select Range("A7").FormulaR1C1 = "206" Range("A7").Select End Sub Code Trees Range("C2").Select ActiveCell.FormulaR1C1 = "1" Range("D2").Select ActiveCell.FormulaR1C1 = "WindBreakers" Range("C3").Select ActiveCell.FormulaR1C1 = "2" Range("D3").Select ActiveCell.FormulaR1C1 = "Forest Incentive" Range("C4").Select ActiveCell.FormulaR1C1 = "3" Range("D4").Select ActiveCell.FormulaR1C1 = "Spring protection" Range("C5").Select ActiveCell.FormulaR1C1 = "4" Range("D5").Select ActiveCell.FormulaR1C1 = "Shading" Range("C6").Select ActiveCell.FormulaR1C1 = "5" Range("D6").Select ActiveCell.FormulaR1C1 = "Conservation" Range("C7").Select ActiveCell.FormulaR1C1 = "6" Range("D7").Select ActiveCell.FormulaR1C1 = "Landscape" End Sub |
All times are GMT +1. The time now is 02:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com