|
-
Oct 15th, 2002, 07:01 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Excel - VBA
How can I specify a cell to use as input and output? I am pretty new to VBA in excel
Last edited by TomGibbons; Oct 15th, 2002 at 01:35 PM.
-
Oct 15th, 2002, 08:24 AM
#2
What are you trying to do here Tom, can you give me an idea of your project as I'm not sure what you're trying to achieve here.
Thanks
-
Oct 15th, 2002, 08:40 AM
#3
Thread Starter
Frenzied Member
It's pretty simple, I'm just not very good at explaining. I want to get text from, and put text in a cell that I know the co-ords of.
Last edited by TomGibbons; Mar 11th, 2004 at 05:48 PM.
-
Oct 15th, 2002, 08:48 AM
#4
ahhh, okay, there's 2 main ways of doing this, either using the Range object, or the Cells object. I personally prefer using the range as it's easier.
To run these, open Excel & add a button onto the spreadsheet. Double click onto the button to get to the code window & enter the following code.
Using the range, you specify the letter of the column & the row number, so the first cell is referenced as A1. This returns a value in a messagbox for you.
VB Code:
Private Sub CommandButton1_Click()
MsgBox Sheets("Sheet1").Range("A1").Value
End Sub
The cells way works backwards, you specify a number for the row first, followed by a number for the column, both of these make up a reference to a cell - so the first cell will be referenced as 1,1. This sample places a value into the cell:
VB Code:
Private Sub CommandButton1_Click()
Sheets("Sheet1").Cells(1, 1).Value = "A Value"
End Sub
-
Oct 15th, 2002, 01:34 PM
#5
Thread Starter
Frenzied Member
Thanks alot Alex
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|