Solved

excel - vba subroutine example

Posted on 2004-10-05
3
949 Views
Last Modified: 2012-06-27
I want based on the current cell (activecell) to mark 5 cells on the right of the specific cell in the same row and paste it in a field starting in cell BP1

excel - vba subroutine

thanks
0
Comment
Question by:fzd
3 Comments
 
LVL 11

Accepted Solution

by:
huntersvcs earned 50 total points
Comment Utility
If you want a single value from a single cell, use this:

x = ActiveCell.Address
    ActiveCell.Offset(rowoffset:=0, columnoffset:=5).Select
    y = ActiveCell.Value
    Range(x).Select
    Range("BI1").Value = y

If you want all 5 cell values, try this (it's primitive, but it works):

    x = ActiveCell.Address
    ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Select
    a = ActiveCell.Value
    ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Select
    b = ActiveCell.Value
    ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Select
    c = ActiveCell.Value
    ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Select
    d = ActiveCell.Value
    ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Select
    e = ActiveCell.Value
    Range(x).Select
    Range("BP1").Value = a
    Range("BQ1").Value = b
    Range("BR1").Value = c
    Range("BS1").Value = d
    Range("BT1").Value = e

You don't need to copy and paste - merely set the Range values.  It's faster and you have no problems with refresh rates.

Hope this helps.
Rick
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now