Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
For example.
I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
#2
![]() |
|||
|
|||
![]()
Hi Andrzej
Are these your actual file names, or is one a name, and the other could be any file? Are you satisfied that the active cell in P2.xls will always be correct? You need VB code to open and search p1.xls for the phrase AAA, and code to thenwrite in the activecell of p2.xls, provided that AAA is found "Andrzej" wrote: For example. I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
#3
![]() |
|||
|
|||
![]()
Ok
Do you know that VB code?? U¿ytkownik "Kassie" napisa³ w wiadomo¶ci ... Hi Andrzej Are these your actual file names, or is one a name, and the other could be any file? Are you satisfied that the active cell in P2.xls will always be correct? You need VB code to open and search p1.xls for the phrase AAA, and code to thenwrite in the activecell of p2.xls, provided that AAA is found "Andrzej" wrote: For example. I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
#4
![]() |
|||
|
|||
![]()
Hi Andrzej
I take it your answer to my questions was "yes". If so, open p2.xls, press<Alt<F11, click on Insert|Module, and paste the following code the Obviously, you must replace my C: path with your own. Also, you must insert the code for what you want to insert in the active cell (replace "asdf") Sub FindIt() Workbooks.Open Filename:= _ "C:\Documents and Settings\J Kasselman\My Documents\p1.xls" Dim notthere As Range Set notthere = Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False) If notthere Is Nothing Then MsgBox "AAA was not found" ActiveWorkbook.Close Exit Sub Else Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate ActiveWorkbook.Close ActiveCell.Formula = "asdf" End If "Andrzej" wrote: Ok Do you know that VB code?? U¿ytkownik "Kassie" napisa³ w wiadomo¶ci ... Hi Andrzej Are these your actual file names, or is one a name, and the other could be any file? Are you satisfied that the active cell in P2.xls will always be correct? You need VB code to open and search p1.xls for the phrase AAA, and code to thenwrite in the activecell of p2.xls, provided that AAA is found "Andrzej" wrote: For example. I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
#5
![]() |
|||
|
|||
![]()
Hi Kassie,
thank for answer I wanted something like this, but not to end. Maybe I write a bit more about my project. In my second file (p2.xls) I have button. This his code: Private Sub CommandButton2_Click() Dim Cecha As String Cecha = InputBox("Podaj nazwe cechy (Enter the name)", "Wprowad¼ warto¶æ (Enter value)") If Cecha = "" Then Exit Sub '--- and in this place I need VB code , which search p1.xls IF will found in any cell value with variable Cecha THEN write in ActiveCell (in p2.xls) value Cecha ' Do you know Polish language? :) ELSE MsgBox ("Przykro mi, ale (Sorry, but) " & Cecha & " nie znaleziono (was not found)") End If End Sub I hope so, we understood each other now. Please help me if you can. U¿ytkownik "Kassie" napisa³ w wiadomo¶ci ... Hi Andrzej I take it your answer to my questions was "yes". If so, open p2.xls, press<Alt<F11, click on Insert|Module, and paste the following code the Obviously, you must replace my C: path with your own. Also, you must insert the code for what you want to insert in the active cell (replace "asdf") Sub FindIt() Workbooks.Open Filename:= _ "C:\Documents and Settings\J Kasselman\My Documents\p1.xls" Dim notthere As Range Set notthere = Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False) If notthere Is Nothing Then MsgBox "AAA was not found" ActiveWorkbook.Close Exit Sub Else Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate ActiveWorkbook.Close ActiveCell.Formula = "asdf" End If "Andrzej" wrote: Ok Do you know that VB code?? U?ytkownik "Kassie" napisa3 w wiadomo?ci ... Hi Andrzej Are these your actual file names, or is one a name, and the other could be any file? Are you satisfied that the active cell in P2.xls will always be correct? You need VB code to open and search p1.xls for the phrase AAA, and code to thenwrite in the activecell of p2.xls, provided that AAA is found "Andrzej" wrote: For example. I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
#6
![]() |
|||
|
|||
![]()
)Hi Andrzej
My Polish is non existent. I do not have the code to recreate some of your characters. Please correct the ommissions (1/4 after Wprowad and special characters after warto! For the rest, I am sure this is what you were looking for! Sub Macro3() Cecha = InputBox("Podaj nazwe cechy", "Wprowad warto") If Cecha = "" Then Exit Sub Workbooks.Open Filename:= _ "C:\Documents and Settings\J Kasselman\My Documents\p1.xls" Dim notthere As Range Set notthere = Cells.Find(What:=Cecha, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False) If notthere Is Nothing Then MsgBox "Przykro mi, ale" & Cecha & "nie znaleziono" ActiveWorkbook.Close Exit Sub Else Cells.Find(What:=Cecha, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate ActiveWorkbook.Close ActiveCell.FormulaR1C1 = Cecha End If End Sub "Andrzej" wrote: Hi Kassie, thank for answer I wanted something like this, but not to end. Maybe I write a bit more about my project. In my second file (p2.xls) I have button. This his code: Private Sub CommandButton2_Click() Dim Cecha As String Cecha = InputBox("Podaj nazwe cechy (Enter the name)", "Wprowad¼ warto¶æ (Enter value)") If Cecha = "" Then Exit Sub '--- and in this place I need VB code , which search p1.xls IF will found in any cell value with variable Cecha THEN write in ActiveCell (in p2.xls) value Cecha ' Do you know Polish language? :) ELSE MsgBox ("Przykro mi, ale (Sorry, but) " & Cecha & " nie znaleziono (was not found)") End If End Sub I hope so, we understood each other now. Please help me if you can. U¿ytkownik "Kassie" napisa³ w wiadomo¶ci ... Hi Andrzej I take it your answer to my questions was "yes". If so, open p2.xls, press<Alt<F11, click on Insert|Module, and paste the following code the Obviously, you must replace my C: path with your own. Also, you must insert the code for what you want to insert in the active cell (replace "asdf") Sub FindIt() Workbooks.Open Filename:= _ "C:\Documents and Settings\J Kasselman\My Documents\p1.xls" Dim notthere As Range Set notthere = Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False) If notthere Is Nothing Then MsgBox "AAA was not found" ActiveWorkbook.Close Exit Sub Else Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate ActiveWorkbook.Close ActiveCell.Formula = "asdf" End If "Andrzej" wrote: Ok Do you know that VB code?? U?ytkownik "Kassie" napisa3 w wiadomo?ci ... Hi Andrzej Are these your actual file names, or is one a name, and the other could be any file? Are you satisfied that the active cell in P2.xls will always be correct? You need VB code to open and search p1.xls for the phrase AAA, and code to thenwrite in the activecell of p2.xls, provided that AAA is found "Andrzej" wrote: For example. I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
#7
![]() |
|||
|
|||
![]()
And define Cecha for best practice, as in your own code. I forgot to define
it. "Andrzej" wrote: Hi Kassie, thank for answer I wanted something like this, but not to end. Maybe I write a bit more about my project. In my second file (p2.xls) I have button. This his code: Private Sub CommandButton2_Click() Dim Cecha As String Cecha = InputBox("Podaj nazwe cechy (Enter the name)", "Wprowad¼ warto¶æ (Enter value)") If Cecha = "" Then Exit Sub '--- and in this place I need VB code , which search p1.xls IF will found in any cell value with variable Cecha THEN write in ActiveCell (in p2.xls) value Cecha ' Do you know Polish language? :) ELSE MsgBox ("Przykro mi, ale (Sorry, but) " & Cecha & " nie znaleziono (was not found)") End If End Sub I hope so, we understood each other now. Please help me if you can. U¿ytkownik "Kassie" napisa³ w wiadomo¶ci ... Hi Andrzej I take it your answer to my questions was "yes". If so, open p2.xls, press<Alt<F11, click on Insert|Module, and paste the following code the Obviously, you must replace my C: path with your own. Also, you must insert the code for what you want to insert in the active cell (replace "asdf") Sub FindIt() Workbooks.Open Filename:= _ "C:\Documents and Settings\J Kasselman\My Documents\p1.xls" Dim notthere As Range Set notthere = Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False) If notthere Is Nothing Then MsgBox "AAA was not found" ActiveWorkbook.Close Exit Sub Else Cells.Find(What:="AAA", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate ActiveWorkbook.Close ActiveCell.Formula = "asdf" End If "Andrzej" wrote: Ok Do you know that VB code?? U?ytkownik "Kassie" napisa3 w wiadomo?ci ... Hi Andrzej Are these your actual file names, or is one a name, and the other could be any file? Are you satisfied that the active cell in P2.xls will always be correct? You need VB code to open and search p1.xls for the phrase AAA, and code to thenwrite in the activecell of p2.xls, provided that AAA is found "Andrzej" wrote: For example. I have two files: p1.xls and p2.xls In p1.xls in unknown Cells value = "AAA" or differend string.. and this file isn't open. and I would like to write in to the file p2.xls in to ActiveCell something, but only if i find in file p1.xls lalue "AAA" . You know what I want isn't it? I hope so. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find File | Excel Discussion (Misc queries) | |||
Can't always find XLA file | Excel Discussion (Misc queries) | |||
the system cannot find file specified | Excel Discussion (Misc queries) | |||
Read Text File into Excel Using VBA | Excel Discussion (Misc queries) | |||
Windows cannot find file message | Excel Discussion (Misc queries) |