473,791 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10131
On Wed, 05 Nov 2008 00:18:29 GMT, "Stratocast er" <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, "Stratocast er" <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").Off set(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.Cha rtObjects("Char t 1").Activate
ActiveChart.Cha rtArea.Select
ActiveChart.Ser iesCollection.N ewSeries.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
15484
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 multiple> elements. Am I missing something obvious? Sincerely, TJ Walls
3
28559
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 figure it out. Here is my sample code: import win32com.client xl=win32com.client.Dispatch("Excel.Application") xl.Visible=1 wb = xl.Workbooks.Add( )
5
1469
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, constructed in a DataGrid. Then what I want is select a range of two dates in that same calendar to do any action.
4
2815
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 can I translate the code, in MS-Excel, below in a equivalent code in MS-Access ........................................................................................... Sub convSelExtPIDToShortPID()
7
2050
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 to do is, calculate the differnce between cells for each column and write it to a file. for example, since there is no previous value to row one, write first row to a file. then subtrack second raw values from the first row values and write the...
1
2435
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 which allows the user to put in critera. I want to be able to click a button on Form 2 that will run the Macro after the criteria has been entered. What would be recommended? Thank You.
0
1063
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 if not possible then so be it. I cannot even find a menu selection that will let me save a selected range of cells from a worksheet so I can't run a macro and then borrow the code. From what I can find online is to use GetFromClipboard with...
9
3384
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
2012
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
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.