473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Select Cells, and performing macro on selected cells?

Hello, and thank you for any help in advance.

I need help determining if any commands exist in VB (Excel macro style) that
can enable a user to select cells and run a macro which performs operations
on those cells. I am a beginner and am not sure if this is possible.

And if you'd really like to teach me a lesson. . . .

Could this be iterated with a while loop?
Suppose I wanted to simply make a graph of each row in a dataset and each
graph also contains the last line in the set (so two rows being graphed, one
fixed and one iterated). Assuming I had 10 rows (labels in Row 1 and Column
1) I would want a seperate graph for each of the following pairs of rows:
{(2,10), (3,10), . . . (9,10)}. Is this possible? If so, would you offer
me any wisdom on how I could set this up?

Until this point, record macro has been my only reliable source of
information since I do not seem capable of looking up the magical command
statements in the help menu to enable these actions. Again thank you for
any help or advice.

Thank you

Nov 5 '08 #1
2 10105
On Wed, 05 Nov 2008 00:18:29 GMT, "Stratocaster" <st****@verizon.net>
wrote:
>Hello, and thank you for any help in advance.

I need help determining if any commands exist in VB (Excel macro style) that
can enable a user to select cells and run a macro which performs operations
on those cells. I am a beginner and am not sure if this is possible.

And if you'd really like to teach me a lesson. . . .

Could this be iterated with a while loop?
Suppose I wanted to simply make a graph of each row in a dataset and each
graph also contains the last line in the set (so two rows being graphed, one
fixed and one iterated). Assuming I had 10 rows (labels in Row 1 and Column
1) I would want a seperate graph for each of the following pairs of rows:
{(2,10), (3,10), . . . (9,10)}. Is this possible? If so, would you offer
me any wisdom on how I could set this up?

Until this point, record macro has been my only reliable source of
information since I do not seem capable of looking up the magical command
statements in the help menu to enable these actions. Again thank you for
any help or advice.
Whilst VBA (Visual Basic for Applications) shares a lot of syntax with
VB Classic, it also has some differences :)

Record Macro is your best friend when first learning VBA, record a
task, then look at the code generated, and abstract it to a general
case that you can use.

Read the VBA help files as well, from within code view you can
highlight a command then press F1 to get taken to that section of help
directly, or start with the 'MS Excel VB Reference->Programming
Concepts' section which leads you through how to select and activate
ranges, etc.

You'll want to read up on; Range (object), Selection (property), and
Offset (property).

Also you might want to find a gentle starter tutorial to help you
understand the basic object model, syntax, working with collections,
etc, such as http://www.anthony-vba.kefra.com/index_011.htm or
http://pubs.logicalexpressions.com/P...Search&AUTH=33
--
Alfie [UK]
<http://www.delphia.co.uk/>
What happens if you install windows 98 on a system with 2 processors? It crashes twice.

Nov 5 '08 #2
On Fri, 14 Nov 2008 03:33:35 GMT, "Stratocaster" <st****@verizon.net>
wrote:
>Thanks for your input Alfie.
You're welcome :)
>However, this also forces Excel to graph all empty columns and the result is
ugly. So then, how could I perform this graphing loop so that future
updates would be recognized by these graphs?
There are 2 things you need to do, firstly work out what range you
need, then assign that into a data series.

To work out how far a row of data extends you can use a loop to scan
for empty cells, although this will depend upon how your data is laid
out. For instance;

Dim cnt As Long
cnt = 0
Do While Range("A1").Offset(1, cnt) <""
cnt = cnt + 1
Loop

....will step through the second row looking for an empty cell, cnt
will then hold the (R1C1 format) column offset of the first empty
cell.

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection.NewSeries.Values = "=R2C1:R2C" & cnt

....will then add that series to the chart (you may get anomalous
results if that series is already included in the chart).

These are rather rough and ready solutions though, it's been a while
since I had to use Excel in any real capacity, and may not fit your
data series, but might give you another angle to approach it from.
--
Alfie [UK]
<http://www.delphia.co.uk/>
Some people drink from the fountain of knowledge...I think you barely gargled.

Nov 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: TJ Walls | last post by:
Hello All, Is it possible to create a <select> element with no selected options? I have tried setting the selectedIndex attribute to -1, but as far as I can tell this only works for <select...
3
by: zxo102 | last post by:
Hi there, I need your help for python <--> excel. I want to paste selected cells (range) to different location on the same sheet in Excel through python. I have tried it for a while but could not...
5
by: ruca | last post by:
Hi, Can anyone give me examples of how can I hightlight cells of my datagrid? I know that I must use ItemBound event and probably JavaScript. The thing is that I have a anual calendar,...
4
by: mimasci | last post by:
Hi, I have tried to write a code that allowed me to modify the value of the cells selected in a table, with excel has been easy. How one approaches selected cells? (To modify the value) How...
7
by: gsaray101 | last post by:
there is a csv file like this: date, val1, val2, val3, val4 etc 1/2/2007, 1, 4, 5, 6 1/3/2007, 2, 5, 7, 10 1/5/2007, 5, 6, 8, 11 what I need...
1
by: kaosx5 | last post by:
I have a report sceniro where I have the user select a Report(acutally it is a macro but didn't want to confuse the user) off of Form1. When the user double clicks the Macro name it opens Form 2...
0
ebs57
by: ebs57 | last post by:
Does anyone know how to easily and programmatically save a range of cells with Excel VBA to a CSV, text or other file? It would be nice if I did not have to create another worksheet first, too, but...
9
by: Lopy | last post by:
Hi, Can anybody tell me how Can I find out a indexes of cells which are selected? E.g: when I want to delete a content a cells. thanx
2
by: ManuelValdez | last post by:
Hello! I need your help to design an Excel macro to delete zeros only in selected cells. Thank you very much.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.