View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
Cecilkumara Fernando[_2_] Cecilkumara Fernando[_2_] is offline
external usenet poster
 
Posts: 93
Default EXCEL VBA question


"Grace" skrev i melding
...
Perhaps I am confused but I don't think you have answered my question.

What
I do is copy data from a source file to the same location in a destination
file. I do this for many different areas on many different tabs.

So, I go to the source file (which you have called F) and I highlight,

say,
worksheet tab 1, then a range of cells on that tab. Then I activate the
destination file, find the same tab and same cell area and paste it.

Then, I go back to the source file and repeat for another tab and area.

So,
each time I am toggling between two files. I was trying to find a way to
call the source file each time. I thought the command:


Grace,

"Harald Staff" wrote in message
...
"Grace" skrev i melding
...

Usually one doesn't have to select or activate anything to move/copy stuff
from one place to another. It just slows things down while looking ugly.

Best wishes Harald

The code below will list out the names of all opened windows in columnH, and validate the cell G1
with a dropdown list to select one from it.

Sub ListMyWBks()
For i = 1 To Windows.Count
Range("H" & i).Value = Windows(i).Caption
Next i
With Range("G1").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="=$H$1:$H$10"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub

I made the above list in Sheet6 of my source file and select one of the destination file
then select the range I want to copy (activecell of the selection is Top Left cell)
and run this macro

Sub CopyData()
DesWB = Sheets("Sheet6").Range("G1").Value
DesShName = ActiveWorkbook.ActiveSheet.Name
DesCell = ActiveCell.Address

Selection.Copy _
Destination:=Workbooks(DesWB) _
.Sheets(DesShName).Range(DesCell)
End Sub

when that file is done go to sheet6 and select another file
if same location in a destination file = True for the sheet name too
above will ease your life to some extend.

HTH
Cecil