REAL-TIME

VBA Projects

Full Access with Source Code
  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

Effortlessly
Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post

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.

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.

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Categories: Excel VBATags: Last Updated: June 17, 2022

6 Comments

  1. Paudel October 19, 2014 at 1:08 PM

    helloo i am new to vba
    how can i pick numbers form certain cell and add text to it. eg i have 2014 5 6 in different cells i want vba programme to select each cells and write in another one cell 2014 year 5 month 6 days

  2. PNRao October 20, 2014 at 6:43 PM

    Hi Paudel,
    Assuming that you have data at Range A1(2014), B1(5), C1(6). You can combine and print this into D1 as follows:

    Range(“D1”)=Range(“A1″)&”year ” &Range(“B1″) &”month ” &Range(“B1″) &”days”

    Hope this helps!
    Thanks-PNRao!

  3. Patti November 20, 2014 at 9:24 PM

    I am trying to remove the first 4 characters from a list of file names. Can someone help me create a code to move down a list removing the first 4 characters from the data in each cell? Recording my actions did not give me the results I was hoping for.

  4. Jimmy December 19, 2014 at 3:44 AM

    Just use right(“A1”,len(“A1”)-4) Assuming it’s for A1, for the sake of this exercise.

  5. Ravichandran Rajagopal January 23, 2016 at 8:19 AM

    Help assistance required.
    I have two sheets.
    In Sheet 1, A1 I have todays date.
    In sheet 2, from A1 to A30 I have the dates of the month. B1…. Z30 I have various other data.

    I want to write a macro so that A32….. Z30 gets filled with data pertaining to the date that is in Sheet 1, A1. Kindly help.

  6. Sandeep November 1, 2016 at 4:07 PM

    This is a simple task that can be done with simply using VLOOKUP(). Why would you want to have a macro for this when you can simply get it done by using a single formula?

Leave A Comment