2017-04-04 4 views
0

私はこれを行うことができます。しかしvba私はコード簡単な単語を知りません A1 = "メロディーズレッドドラゴン"VBAのCellFind関数

"赤"を検索します。見つかった場合は "赤" =はい赤です。どのように質問そのOK質問範囲A1 =メロディーレッドDragraonこの

Range("A3").Select 
Cells.Find(What:="red", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ 
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ 
    , SearchFormat:=False).Activate 

を書いたり、興味に私はあなたが私は偉大な

を見つけ=範囲A1 A2に赤い見つかった場合は範囲​​A1「赤」からテキストを検索しますあなたが見つけ

Dim codebranch As String 
Dim branchname As String 
Dim lictype As String 
On Error GoTo errHandler 

lictype = Mid(Range("B5"), 48, 7) 

私の輸出PDF旧コードにピュイたいgreat_All _003_Lumpini_03_04_60.pdf

完全なコードPDFここ

Sub Button28_PDF() 
Dim wsA As Worksheet 
Dim wbA As Workbook 
Dim strTime As String 
Dim strName As String 
Dim strPath As String 
Dim strFile As String 
Dim strPathFile As String 
Dim myFile As Variant 
Dim codebranch As String 
Dim branchname As String 
Dim lictype As String 
On Error GoTo errHandler 


lictype = Mid(Range("B5"), 48, 7) 
codebranch = Left(Range("A1"), 3) 
branchname = Mid(Range("A1"), 7, 50) 
Set wbA = ActiveWorkbook 
Set wsA = ActiveSheet 
strTime = Format(Now(), "dd_mm_yy") 

'get active workbook folder, if saved 
strPath = wbA.Path 
If strPath = "" Then 
strPath = Application.DefaultFilePath 
End If 
strPath = strPath & "\" 

'replace spaces and periods in sheet name 
strName = Replace(wsA.Name, " ", "") 
strName = Replace(strName, ".", "_") 

'create default name for savng file 
strFile = lictype & "_" & codebranch & "_" & branchname & "_" & strTime & ".pdf" 
strPathFile = strPath & strFile 

'use can enter name and 
' select folder for file 
myFile = Application.GetSaveAsFilename _ 
(InitialFileName:=strPathFile, _ 
     FileFilter:="PDF Files (*.pdf), *.pdf", _ 
     Title:="Select Folder and FileName to save") 

'export to PDF if a folder was selected 
If myFile <> "False" Then 
    wsA.ExportAsFixedFormat _ 
     Type:=xlTypePDF, _ 
     Filename:=myFile, _ 
     Quality:=xlQualityStandard, _ 
     IncludeDocProperties:=True, _ 
     IgnorePrintAreas:=False, _ 
     OpenAfterPublish:=False 
     'confirmation message with file info 
    MsgBox "PDF file has been created: " _ 
     & vbCrLf _ 
     & myFile 
End If 

exitHandler: 
    Exit Sub 
errHandler: 
    MsgBox "Could not create PDF file" 
    Resume exitHandler 
End Sub 
+0

いくつかの詳細(例?)あなたの目標についてのお願い – user3598756

答えて

0

このような何か...

Dim Rng As Range 
'Range("A3").Select 
Set Rng = Cells.Find(What:="red", After:=Range("A3"), LookIn:=xlFormulas, LookAt:= _ 
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ 
    , SearchFormat:=False) 
If Not Rng Is Nothing Then 
    'do whatever you want to do with Rng cell found 
End If