VBA & Macro Problems

Fix an Excel VBA Loop That Writes Every Result to C2

Aamir Naveed AkramAamir Naveed Akram Nov 25, 2026 868 views

Question details

The user needs an Excel VBA loop to write each web result to the column C cell on the same row as its column A input.

Fix an Excel VBA Loop That Writes Every Result to C2
Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
A macro loops through values in column A and retrieves a web result for each value.
Observed behavior
The macro repeatedly writes results to the fixed cell C2 instead of advancing down column C.
Before you start

Open the workbook containing the macro and identify the loop variable that refers to each cell in column A. Confirm that column C is the intended output column and that overwriting its existing values is acceptable.

Solution 1Recommended

Use the Current Loop Cell to Write Each Result to Column C

Replace the fixed C2 destination with an offset from the current column A cell so each result goes to the matching row.

If rngC refers to the current cell in column A, Offset(0, 2) selects the cell on the same row, two columns to the right. For example, A2 maps to C2 and A3 maps to C3.

1
Open the macro

In Excel, open the Developer tab and select Visual Basic. In the VBA editor, open the module containing the loop.

2
Find the fixed destination

Inside the loop, locate the statement that writes the web result to Range("C2"). Confirm that rngC is the variable for the current column A cell; if your loop uses another name, use that variable instead.

3
Replace the output statement

Replace the fixed-cell assignment with: rngC.Offset(0, 2).Value = icstatus(1).TextContent. Keep this statement inside the loop after the code that retrieves the current row's web result.

4
Test the loop

In the VBA editor, place the cursor in the macro and select Run > Run Sub/UserForm. Check that results for A2, A3, and subsequent input cells appear in C2, C3, and their matching rows.

Use the Current Loop Cell to Write Each Result to Column C
Check the source column: The offset of two columns assumes rngC is in column A. If the loop variable points to a different column, adjust the offset to reach column C.
Free Microsoft Office alternative

Work With Excel Spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for easier migration. Use it to view and edit spreadsheet data; it does not fix an Excel VBA macro, and macro compatibility should be checked separately.

Review and edit column-based spreadsheet data in WPS SpreadsheetsOpen and save Microsoft Excel XLSX files for convenient sharingNavigate spreadsheets with a familiar Office-style interfaceUse a free, lightweight office suite for everyday work
microsoft office alternative - wps office

Frequently Asked Questions

Why does my VBA loop keep overwriting C2?

A statement such as Range("C2").Value always targets C2, regardless of the loop's current row. Replace it with an offset from the current loop cell to advance the output with each input.

What does rngC.Offset(0, 2) mean?

It selects a cell on the same row as rngC and two columns to its right. If rngC is A4, rngC.Offset(0, 2) refers to C4.

What if my loop variable is not named rngC?

Use the variable named in your For Each loop instead. For example, if the loop uses cell, write cell.Offset(0, 2).Value = icstatus(1).TextContent, provided cell refers to a column A cell.

How can I check which cells the macro is writing to?

Open the macro through Developer > Visual Basic and use Debug > Step Into to run it one statement at a time. Check the current loop cell and its offset as the loop advances.