Be the first user to complete this post

  • 0
Add to List

VBA Excel – Looping Through a Range of Cells

Referring Excel cells using For…Next -Loop

For i = 1 to 10

Range(“A” & i).Value = 1

Next

Enter ‘1’ in Cells from A1 to A10.

Referring Columns of excels using For-Loop

For i = 1 To 26

Range(Chr(65 + i) & "1").Value = 2

Next

Enter ‘2’ in cells from A1 to Z1

Referring Excel cells using For…Each…Next –Loop

For Each i In Sheet1.Range("H1:H5")

i.Value = 10

Next

Enter ‘10’ in Cells from H1 to H5.



Also Read:

  1. VBA-Excel: Array Functions – Join() – Converts Array to String
  2. VBA-Excel: Date-Time Functions – Day()
  3. Excel-VBA : Prevent Adding New Worksheet
  4. Getting Started with Excel Macro
  5. VBA Excel - Cells, Ranges and Offset : Cells
  6. VBA-Excel: Copy/Paste data - Copy the Entire row data and paste it to another row
  7. VBA-Excel: Arrays – One Dimension, Dynamic Array
  8. VBA Excel - Cells, Ranges and Offset : Offset