Solved

excel - vba subroutine example

Posted on 2004-10-05
3
1,001 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
ID: 12240517
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…

733 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