llawrenceg
asked on
Value pasting to wrong workbook
I have a workbook that inserts the time to cell C15. However when I have another workbook open the time is inserted to cell C15 of the active workbook. How to I prevent this from occurring?
Snippet from code that puts the data and time in the C15 cell
of the Active workbook when I need it in
ThisWorkbookSheets(1).Range C15
Set TimeC = range("C15")
TimeC = TimeC.Value
range("B15").Value = Left(Trim(range("B15").Value), 12)
MyData.SetText ""
MyData.PutInClipboard
TimeC.Value = Date & ":" & Time
Set TimeC = ThisWorkbook.Range("C15") 'where the code is running
TimeC = TimeC.Value
Now that TimeC is pointed to the right workbook, the rest of your code should be fine.
Dave
TimeC = TimeC.Value
Now that TimeC is pointed to the right workbook, the rest of your code should be fine.
Dave
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great Guys , I needed to know where to put it and you told me.
Thanks Works perfectly
Thanks Works perfectly
ThisWorkbook.Range("C15")
Dvae