View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Assign cell value to variable

Dim shA as Worksheet
Dim shB as Worksheet
set shA = WorkBooks("WorkbookA.xls").Worksheets("WorksheetA" )
set shB = WorkBooks("WorkbookB.xls").Worksheets("WorksheetB" )

for i = 1 to 10
for j =1 1 to 5
shA.Cells(i,j).Value = shB.Cells(i,j).Value
Next j
Next i

or
shA.Range("A1:F10").Value = shB.Range("A1:F10").Value

to use a variable

for i = 1 to 10
for j =1 1 to 5
v = shB.Cells(i,j).Value
shA.Cells(i,j).Value = v
Next j
Next i

--
Regards,
Tom Ogilvy




"Rookie_User" wrote:

I know this is very basic but I have two workbooks open and I declare (DIM)
and assign all workbook names and worksheet names. I simply want to take
values from specfic cells in workbookA.WorksheetA.Cell A1 and assign it to a
variable and then goto workbookB.etc. and put the value in cell A1.

How can I do this efficiently and then also how can I do this using variables?

Thanks....