Solved

excel - vba subroutine example

Posted on 2004-10-05
3
1,014 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 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

Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

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

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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…

687 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