?
Solved

excel - vba subroutine example

Posted on 2004-10-05
3
Medium Priority
?
1,025 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Accepted Solution

by:
huntersvcs earned 200 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

Industry Leaders: 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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

650 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