Description:

While working with Excel it is common task to writing and reading the Workrksheet. For example, we may have a Input data sheet to enter data, based on the data in Input sheet we can perform some calculations and show the results to the user.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

BROWSE ALL TEMPLATES

50+ Project Management Templates Pack
Excel PowerPoint Word

VIEW DETAILS

Advanced Project Plan & Portfolio Template
Excel Template

VIEW DETAILS

Ultimate Project Management Template
Excel Template

VIEW DETAILS

20+ Excel Project Management Pack
Excel Templates

VIEW DETAILS

20+ PowerPoint Project Management Pack
PowerPoint Templates

VIEW DETAILS

10+ MS Word Project Management Pack
Word Templates

VIEW DETAILS


Writing and Reading Excel Worksheet Cells Ranges in VBA – Solution(s):

Delete Worksheet in Excel VBA We can use Cell or Range Object as discussed in the previous topics to read and write the using VBA. The following example will show you how write and read the data using Excel VBA.

Example1 : Reading and Writing the data using Cell Object

In this example I am reading the data from Range B3 and Writing the data into C5 using Cell Object.

Sub sbReadWriteCellExample1()

'Using Cell Object
Cells(5, 3) = Cells(3, 2)
MsgBox Cells(5, 3)
End Sub
Example2 : Reading and Writing the data using Range Object

In this example I am reading the data from Range B3 and Writing the data into C5 using Range Object.

Sub sbReadWriteCellExample2()

'Using Range Object
Range("C5") = Range("B3")
MsgBox Range("C5")

End Sub
Example3 : Reading and Writing the data using Cell and Range Object

Even we can use combination of Cell and Range. In this example I am reading the data from Range B3 and Writing the data into C5 using Cell and Range Object.

Sub sbReadWriteCellExample3()

'Using Cell and Range Object
Cells(5,3) = Range("B3")
MsgBox Cells(5,3)

'OR
'Range("C5")=Cells(3,2)  
'MsgBox Range("C5")

End Sub
Example4 : Reading and Writing the data – From different Worksheets

We can mention the Sheet name while reading the data from another sheet.

Sub sbReadWriteCellExample3()

'Using Cell and Range Object
Cells(5,3) = Sheets("Sheet5").Range("B3")
MsgBox Cells(5,3)


End Sub
Example4 : Reading and Writing the data – Write to different Worksheets

We can mention the Sheet name while Writing the data to another sheet.

Sub sbReadWriteCellExample3()

'Using Cell and Range Object
Sheets("Sheet5").Cells(5,3) = Range("B3")

MsgBox Sheets("Sheet5").Cells(5,3)

End Sub

Similarly, we can use the workbook names, if you want to write into different workbooks.

LIMITED TIME OFFER - Get it Now!
Advanced Project Plan Excel Template

 
Related Resource External VBA Reference