Calling to a specific cell
I can't seem to find a way to place a cell's location in
a variable or how to call a cell from another sheet. Basically I need a macro running on sheet 2 to call A3 on sheet1 and report the value stored there. Any suggestions? |
Calling to a specific cell
if you want to get anything done in VBA you must
study cell and range referencing. just asking for a quick answer here wont help. ALL vba books i ever read contain many pages on the subject. I woud have plenty of suggestions... except you need to understand rather then copy it. Which workbook are we talking about? the currently active workbook =Activeworkbook the workbook in which the code is running =Thisworkbook or a specific workbook =Workbooks("vbaLesson1") How do you want to refer to the sheets? Use the currently activesheet =ActiveSheet Use the first sheet in the workbook =Worksheets(1) or a specific worksheet =Worksheets("sheet1") etc you're question is ambiguous.. so this is what i make of it: if activesheet.name = "sheet2" then activecell=[sheet1!a3] else msgbox "you're not on sheet2" endif keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Kura" wrote: I can't seem to find a way to place a cell's location in a variable or how to call a cell from another sheet. Basically I need a macro running on sheet 2 to call A3 on sheet1 and report the value stored there. Any suggestions? |
Calling to a specific cell
Eh... its much more simple than that. Basically I just
need to know how to call up a cell from sheet1 of WorkBook1 by running a macro on sheet2 of the same workbook. PseudoCode run by clicking a command button on sheet2: dim flagValue as integer flagValue=Sheet1:a3.value Sheet2:d12.value=flagValue That's roughly what I'm trying to do, but I haven't been able to figure out how to reference the specific cells. I know how to do most other features and have a rather extensive background with VB5, but I've never used anything with cells like this. -----Original Message----- if you want to get anything done in VBA you must study cell and range referencing. just asking for a quick answer here wont help. ALL vba books i ever read contain many pages on the subject. I woud have plenty of suggestions... except you need to understand rather then copy it. Which workbook are we talking about? the currently active workbook =Activeworkbook the workbook in which the code is running =Thisworkbook or a specific workbook =Workbooks ("vbaLesson1") How do you want to refer to the sheets? Use the currently activesheet =ActiveSheet Use the first sheet in the workbook =Worksheets (1) or a specific worksheet =Worksheets ("sheet1") etc you're question is ambiguous.. so this is what i make of it: if activesheet.name = "sheet2" then activecell=[sheet1!a3] else msgbox "you're not on sheet2" endif keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Kura" wrote: I can't seem to find a way to place a cell's location in a variable or how to call a cell from another sheet. Basically I need a macro running on sheet 2 to call A3 on sheet1 and report the value stored there. Any suggestions? . |
Calling to a specific cell
Oops, heh, on closer inspection of your post I was able
to extract a few lines of code and now understand how to reference cells. Thanks for your help! |
Calling to a specific cell
good!.. <vbg
keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Kura" wrote: Oops, heh, on closer inspection of your post I was able to extract a few lines of code and now understand how to reference cells. Thanks for your help! |
Calling to a specific cell
You didn't tell me quite enough. How do you know the
cell's location?? You said "how to call a cell . . .". I don't understand what you mean by "calling" a cell. Do you mean, that while you are in one sheet, you want to get the value of a cell in another sheet? Suppose you are in sheet A and you want a value from a cell in sheet B. If you know that the address of the cell in sheet B is, say, A16, then you can refer to it as: SheetB!A16. Another technique is to give the cell in Sheet B a defined name. To do that, go to sheet B and select cell A16, then in the little box in the upper left of your window that shows "A16", type the name that you want to assign to that cell, then press ENTER. Now if you put your cursor on A16 and look in that box, you should see the name you assigned. Assumming that worked, now you can refer to Sheet B's A16 by its name without any qualification. On Sheet A where you might write A16, now write that defined name. Works like a charm!. -----Original Message----- I can't seem to find a way to place a cell's location in a variable or how to call a cell from another sheet. Basically I need a macro running on sheet 2 to call A3 on sheet1 and report the value stored there. Any suggestions? . |
Calling to a specific cell
Form in a standard module:
Sub Test() Dim flagValue As Integer flagValue = Worksheets("Sheet1").Range("a3").Value Worksheets("Sheet2").Range("d12").Value = flagValue End Sub HTH "Kura" wrote in message ... Eh... its much more simple than that. Basically I just need to know how to call up a cell from sheet1 of WorkBook1 by running a macro on sheet2 of the same workbook. PseudoCode run by clicking a command button on sheet2: dim flagValue as integer flagValue=Sheet1:a3.value Sheet2:d12.value=flagValue That's roughly what I'm trying to do, but I haven't been able to figure out how to reference the specific cells. I know how to do most other features and have a rather extensive background with VB5, but I've never used anything with cells like this. -----Original Message----- if you want to get anything done in VBA you must study cell and range referencing. just asking for a quick answer here wont help. ALL vba books i ever read contain many pages on the subject. I woud have plenty of suggestions... except you need to understand rather then copy it. Which workbook are we talking about? the currently active workbook =Activeworkbook the workbook in which the code is running =Thisworkbook or a specific workbook =Workbooks ("vbaLesson1") How do you want to refer to the sheets? Use the currently activesheet =ActiveSheet Use the first sheet in the workbook =Worksheets (1) or a specific worksheet =Worksheets ("sheet1") etc you're question is ambiguous.. so this is what i make of it: if activesheet.name = "sheet2" then activecell=[sheet1!a3] else msgbox "you're not on sheet2" endif keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Kura" wrote: I can't seem to find a way to place a cell's location in a variable or how to call a cell from another sheet. Basically I need a macro running on sheet 2 to call A3 on sheet1 and report the value stored there. Any suggestions? . |
All times are GMT +1. The time now is 02:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com