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
Solved

excel - vba subroutine example

Posted on 2004-10-05
3
992 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
business objects to connect to MSSQL 6 84
Need a starter for ETL protocol? 4 65
multiple application databases same MSSQL instance 5 70
SSRS troubles 4 69
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
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…

829 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