LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default How to properly read Value2 Range ?

I have two Value2(1) and Value(2) in this test..

Value2(1) is variant (1 to 2)
Value2(2) is variant (1 to 2)

in the first loop it read it right, Value2(1) 1,1 and 1,2

but in the second loop, it don't read right Value(2) 2,1 2,2

Please help if you know how to read it, thanks!

Basically the Range that it reads and sticks into Value2 array ? is
starting at A2:B last row, in this test it is A2:B3 as the range.

A2 has fullpath * filename.xls
B3 has filename.xls needed top execute the Sub within each workbook
that is open, as I understand it

Basically the idea of this VBA Proc is to read from my log which
contains \\network\full\path\filename.xls, open each workbook in the
range and then run a Sub within each one called ADD_BUTTONS.

This works on the first workbooks in range, but then for the Next
Value2:

FileToOpen = Value2(x, 1) - this one has a filename.xls
WrkBookName = Value2(x, 2) - and this one goes blank

FileToOpen has the fullpath & FileName,xls
WrkBookName has just the FineName.xls when I put a watch on them,
they have the right values, but I think I read it wrong
?

Please advise, maybe I am doing it wrong, not a guru :- )


Sub Add_Buttons()

Dim wsLogName As String
Dim wsLog As Worksheet
Dim wsLogRange As Range
Dim FileToOpen, WrkBookName As String
Dim RangeCell As Object

wsLogName = ActiveWorkbook.Name
Set wsLog = ActiveSheet

With wsLog
Sheets("Log").Activate
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
Set wsLogRange = Range("A2:B" & lastrow)
End With

x = 1

For Each Value2 In wsLogRange

FileToOpen = Value2(x, 1)
WrkBookName = Value2(x, 2)
On Error Resume Next

Workbooks.Open Filename:=FileToOpen
' Application.Run (WrkBookName & "!ADD_BUTTONS") ' this
works for manual test: "'test.xls'!ADD_BUTTONS"
' for auto
test: Application.Run (wbTarget.Name & "!MacroName")
ActiveWorkbook.Close SaveChanges:=False

x = 1 + 1

Next

MsgBox "Finished Looping All workbooks from Log and running their Sub
within"

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range.Value2 in C# (Excel 2007, VSTO 2008)? Fabz[_2_] Excel Programming 2 December 8th 09 02:51 PM
Help with Range.Value2, Range.Text and UDFs JsjsLim Excel Programming 6 June 26th 09 05:30 AM
How to Bind VBA Variable to Range().Value2 Property MachAngle Excel Programming 3 April 18th 09 02:26 AM
Excel & C# NullReference Error when trying to set Range.Value2 Chuck Excel Programming 1 August 2nd 06 11:01 PM
Range.Value2 is failing for lenghty strings Naresh Mirkhelkar Excel Programming 4 June 9th 06 02:54 PM


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"