Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using external workbook

Status
Not open for further replies.

kenguru

Programmer
May 14, 2004
173
RO
My problem is that the values the code found don't apper in the choisen workbook. Any idea?
Thanks
Kenguru

I have the following code:
Sub main()

strFile = "Excel Workbooks (*.xls),*.xls,All Files (*.*),*.*"
strFile = Application.GetOpenFilename(strFile, 1, _
"Select Workbook ", , False)
If Len(strFile) < 6 Then Exit Sub ' no file selected

Set wb = Workbooks.Open(strFile, True, True)
compare

wb.Close False ' close workbook without saving changes
Set wb = Nothing
End Sub

Sub compare()
Dim sheet As Integer
Dim keresendo_szo As String

sheet = 3
j = 4

megtalalt = False
For i = 6 To 102
keresendo_szo = Trim(wb.Sheets(sheet).Cells(i, j))
For k = 6 To 1700
If Trim(wb.Sheets(2).Cells(k, j)) = keresendo_szo And megtalalt = False Then
wb.Sheets(sheet).Cells(i, j + 2) = Trim(wb.Sheets(2).Cells(k, j + 2))
megtalalt = True
wb.Sheets(sheet).Cells(i, j + 6) = "ok"
End If
Next k
If megtalalt = False Then
wb.Sheets(sheet).Cells(i, j + 6) = "Not ok"
End If
megtalalt = False
Next i

End Sub
 
My problem is that the values the code found don't apper in the choisen workbook.
can you give more details please?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Theoretical I want to insert data into an excel file but using this macro from another excel file.
 
Theoretical I want to insert data into an excel file BY using this macro from another excel file.
 


Kenguru,

Could you be more specific about what is not working as expected.

Skip,

[glasses] [red][/red]
[tongue]
 

I found the mistake. I was doing right the moddification, onlye I didn't save the file at the end. So I included the following code:
wb.Close SaveChanges:=True

Maybe you could help me on the following problem.
The codes does the following: Opens az excel file, modifies some data on the 3 sheet and after that saves the excel file on the end.
The problem is: doesn't want to save on the same name, because it says that it is open already.

How should I do it?

Thanks for your patient :)
Kenguru
 



Youf workbook is opened as a READ ONLY, if your are using the code posted above.
[tt]
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)
[/tt]


Skip,

[glasses] [red][/red]
[tongue]
 
Yes I'm using the code which appears here. But in my code is the following:
strFile = Application.GetOpenFilename(strFile, 1, _
"Select Workbook ", , False)

and I looked up and i can't seem to find the parameter by what i can set not to be "read-only".

Ideas?
Kenguru
 
Sorry, I miss understanded you. You were right !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top