PDA

View Full Version : Automatically updating into next cell below



phaeom
02-19-2009, 05:31 PM
Hi.
I am quite new with VBA. I am currently working on a small project. I created one macro and a button to update Dow Jones Industrial Average stock data from a website. With this data I created a virtual porfolio next to it and the value of the whole portfolio.
Now what i want to do is have a button so that when i press it it would put a current date (say in Sheet 2) and the value of the whole portfolio next to it. Ideally intraday updates will overwrite the portfolio value but will generate a new date and the portfolio value on that day the next day automatically (once i press the button though).
I know it is quite a lot with conditions in the code etc but this would be absolutely perfect.I appreciate any help or link to a possible solution.
Thanks :bow:

Oorang
02-20-2009, 07:43 AM
Hi Phaeom,
Welcome to the board :) To push data from a cell into another cell you just use something to this effect:
Sub Example()
ThisWorkbook.Sheet2.Range("A1") = Date
ThisWorkbook.Sheet2.Range("A2").Value = Sheet1.Range("D5").Value
End Sub

Does that solve the problem?

phaeom
02-20-2009, 09:49 AM
Hey.
I tried your solution (with dif cell ranges) but it keeps saying:
"Compile error

Method or data member not found"
Highlights .Sheet2 part of the code.I made sure that I have Sheet2 in the workbook.

mdmackillop
02-20-2009, 10:08 AM
Try
Sub Example()
Sheet2.Range("A1") = Date
Sheet2.Range("A2").Value = Sheet1.Range("D5").Value
End Sub

Oorang
02-20-2009, 02:59 PM
It is probably not liking your sheet names, open the Visual Basic Editor (VBE), press ctrl-r to open the Project Explorer. Make sure you are using the Sheet Name not in parentheses.