Skip to main content
Home Programming with Excel VBA
Main navigation
  • Home
  • Lists
    Lessons Exercises Badges Patterns Principles
  • Search
  • Login
Lessons
  • + Getting ready
    • What is the course about?
    • Why should you care?
    • How the course runs
    • Working together
    • Gather.Town
    • Using this site
    • Exercises
    • Feedback
    • When you get stuck
    • How to succeed
    • Set up Excel
    • Your professor
    • Let's get into it!
  • Your learning style
  • + Simple programs
    • The first program
    • Writing the first program
    • Adela's turn
    • Generalize
    • Dialogs
    • Numeric expressions
    • Strings
    • Secluded Cells
    • Easy is good
    • Debugging
    • More debugging
    • Another worked example
    • Exercises
  • + Decisions
    • If-then-else
    • Logical operators
    • Multiway
    • Nested ifs
    • Guard pattern
    • Basic validation: strings
    • Basic validation: numeric
    • Better validation
    • Vladidation in C#
    • Exercises
  • + Data analysis
    • Data tables
    • Ranges
    • Processing a Range
    • Normalizing
    • Range validation
    • Exercise walkthrough
    • Validate then process
    • Filtering
    • Min and max
    • Adela programs
    • Exercises
  • + Tips
    • Blocked macros
    • Common errors
    • Excel objects
    • Excel on Macs
    • Rounding numbers
    • Shortcut keys
    • VBA documentation
    • Pseudents

Input from a cell

Tags
Input
Summary

Get input from a cell.

Situation

You want to get one data value from the user.

Needs

A cell in a worksheet.

Provides

A variable with a value.

Action

Use VBA's Cells function.

Explanation

Example 1

Provides a numeric value. Gets it from cell C2.

  • Dim sRate As Single
  • sRate = Cells(2, 3)

Example 2

Provides a string value. Gets it from cell D1

  • Dim tName As String
  • tName = Cells(1, 4)
Where referenced
Generalize

Creative Commons Attribution-ShareAlike 4.0      Terms of use      Powered by Skilling