For each cell in each row

Stevenn

Active Member
Joined
Feb 8, 2012
Messages
259
I've got some data in several columns in my sheet and want to send it to my access database. I have tried to work with following code:

For Each rngRow In Worksheets("Sheet2").Range("A1:C10").Rows

For Each rngCell In rngRow

MsgBox rngCell.Value

Next

but i can't solve my problem. How can I get the data in each columns in each row?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You were pretty close.
Try this...

Code:
For Each rngCell In Worksheets("Sheet2").Range("A1:C10").Cells
MsgBox rngCell.Value
Next
 
Upvote 0
You were pretty close.
Try this...

Code:
For Each rngCell In Worksheets("Sheet2").Range("A1:C10").Cells
MsgBox rngCell.Value
Next

Thanks for your answer. I would insert a row in my table for each row in my sheet and insert data for each field in each row. I solved my problem with following code

Code:
For Each rngRow In Worksheets("Sheet1").Range("A1:D105").Rows

   objConnection.Execute ("INSERT INTO table (fields) VALUES ('" & rngRow.Columns(1).Value & "')")

Next
 
Upvote 0

Forum statistics

Threads
1,215,078
Messages
6,122,997
Members
449,093
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top