Free Microsoft Excel 2013
Quick Reference
Free Microsoft 2013 Quick Reference Guide

Free Microsoft Excel 2013 Quick Reference

VBA Macro Code To Download/Open File From Internet

Is it possible Click save or open button in popup window while downloading file from web thru vba?


Post your answer or comment

comments powered by Disqus
Hi,

From Vba , I want to download zip files from internet.

And also unzip and then use it.

Any help??

Hi Team,

I am a fresher & new to this group.

Using API function ,I wrote a Macro code to download the file from Internet. This works when I have complete value of the URL. But I want to download the file without entering full value of the URL.

In detail:-.

Each and every day, new files will be updated in my(x.com) website. For example, the URL of the website is www.me.com

URL of the file to Download is http://www.me.com/13jun2008_1200.txt

The standard format of the file name is " DDMONYYYY_HHMM.txt".

Here the problem is ,I know the date part (DDMONYYYY) of the file name but I do not know the exact time(HHMM) value part of the file name.

But I am sure the , only one file will be updated for each day with varying time.
I have to write a code to download the file each day automatically.

Please advise , as like directory file path I cannot specify (*)http://www.me.com/13jun2008_*.txt - This is NOT working.

In VB macro how to find out the valid remaing value of the URL?

Can anybody help me on this. Thanks in advance.

Hi All,

I got the below code, from this site which downloads only one file at one go. I want the macro which will download multiple files from a list of links reflecting in a list box. I have created a userform which has a listbox which gets populated with all download links from where I want to download files. I need the help to implement the below code into my attached download tool userform.

Private Declare Function URLDownloadToFile _
  Lib "urlmon.dll" _
    Alias "URLDownloadToFileA" _
      (ByVal pCaller As Long, _
       ByVal szURL As String, _
       ByVal szFileName As String, _
       ByVal dwReserved As Long, _
       ByVal lpfnCB As Long) As Long
  
Sub DownloadFilefromWeb()

  Const E_OUTOFMEMORY As Long = &H8007000E
  Const E_DOWNLOAD_FAILURE As Long = &H800C0002
  
  Dim InitialName As String
  Dim Msg As String
  Dim RegExp As Object
  Dim RetVal As Long
  Dim SaveName As String
  Dim SavePath As String
  Dim URL As String
  
    URL = InputBox("Enter the download URL below.", "Download from Internet")
    If URL = "" Then Exit Sub
    
    Set RegExp = CreateObject("VBScript.RegExp")
      RegExp.IgnoreCase = True
      RegExp.Pattern = "^(.*/)(.+)$"
      InitialName = RegExp.Replace(URL, "$2")
    Set RegExp = Nothing
      
    If InitialName = "" Or InitialName = URL Then
      MsgBox "Error - Missing File Name"
      Exit Sub
    End If

    SavePath = Application.GetSaveAsFilename(InitialName)
    If SavePath = "" Then Exit Sub
    
    RetVal = URLDownloadToFile(0&, URL, SavePath, 0&, 0&)

    Select Case RetVal
      Case 0
        Msg = "Download Successful"
      Case E_OUTOFMEMORY
        Msg = "Error - Out of Mmemory"
      Case E_DOWNLOAD_FAILURE
        Msg = "Error - Bad URL or Connection Interrupted"
      Case Else
        Msg = "Unknown Error - " & RetVal
    End Select
    
    MsgBox Msg
    
End Sub
Thanks for your help in advance.

Hi All,
I can navigate to certain webpage , and then there is a button download, i click it thru VBA coding after that normal window appeared with three optins (Open , Save , Cancel ). Now i just needs to know how do i click (save) button via vba and then needs to save it in some path. Pleas Help !!!!!

Duplicate thread: http://www.ozgrid.com/forum/showthread.php?t=165771

I have searched and unable to find and work out the code to use. Currently I have a set of VBA code which can pull some existing data from my worksheet A (at c:userMaryfolder 1) and copy the data to an excel file (name : ABC.xls) at c:userJohnfolder 2 and save at c:userJohnfolder 2. However, every time, I move abc.xls file to different location (let say c:userPeterfolder 3), I can to re-type the path again. Is there any code I can use, rather than re-type the path every time when I use different computer?

Hi All,

I want to come up with a macro which will download the most recent file from a URL by checking it's modified date. For example I have the files reflecting on my URL in the below way.

File Name ---------- Modified Date
abc_2010-10-16 --------- 17-10-2010 6.30pm
abc_2010-10-13 ---------- 14-10-2010 7.15pm

The files are not uploaded on regular basis so I can't use the dates as parameters and download the most recent file. I want the macro to check the modified date of all the files which are available on the URL and then download the most recent file from the same consider the name of the same .i.e. it should search for a file the name of which file starts or contains with "abc" and then check it's modified date and download the most recent file from URL.

I have done some research on this and so far I have found some stuff on the below link.

http://forums.techguy.org/business-a...ated-file.html

As of now I have the below code to download the file from a URL.

Private Declare Function URLDownloadToFile
Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000

Public Function DownLoadFileFromIntranet(sSourceUrl As String, _
sLocalFile As String) As Boolean

'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached
'copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownLoadFileFromIntranet = URLDownloadToFile(0&, _
sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function


Sub DownLoadFile()
Dim DownLoadFile As String
Dim sUrl As String

DownLoadFile$ = "c:test down load.txt"
sUrl$ = "Replace this with full url for file to be downloaded"
If DownLoadFileFromIntranet(sUrl, DownLoadFile) = False Then
do something
else
do something else
end if
End Sub
Thanks a lot for your help in advance.

Hello,

What I want to achieve with my current workbook is to retrieve input data from a source file. This needs to be done because active workbooks need to have most current data within there comboboxes. My current macro is to change the current worksheet to copy data from a 'input' file. The problem I'm coming into is if the file exists i get a prompt to ask to override. What I'd is a way to by pass this prompt to override an existing file, or a cleaner method then this shows.


	VB:
	
 getthesource () 
    activesheet.Copy after:=Sheets(Sheets.Count)ActiveWorkbook.SaveAs Filename:="processing" 
    activesheet.Name = "working" 
    Workbooks.Open Filename:="Users:matthewchrycy:desktop:input.xlsx" 
    Application.EnableEvents = False 
    Workbooks("input.xlsx").Sheets("input").Copy after:=Workbooks("processing").Sheets("working") 
    Application.EnableEvents = True 
    Windows("processing").Activate 
    ActiveWorkbook.Sheets("working").Select 
    activesheet.Name = Format(Date, "mmm-dd-yyyy") 
    ActiveWorkbook.SaveAs Filename:=Range("d3") 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
thanks

I know nothing in maacro and codes but interested to use someones sweat,

i got a macro from one of the groups and i use for extracting data from many excel workbooks containing only one worksheet, (inspection request with typical data). here, to extract data required manual intervention to open the folder and selecting files. i need macro to select those files from a given folder without any manual intervention. if someone

thanks in advance

Sub Summary_cells_from_Different_Workbooks_2()
'This example use the function LastRow
Dim FileNameXls As Variant
Dim SummWks As Worksheet
Dim ColNum As Integer
Dim myCell As Range, Rng As Range, fndFileName As Range
Dim RwNum As Long, FNum As Long, FinalSlash As Long
Dim ShName As String, PathStr As String
Dim SheetCheck As String, JustFileName As String
Dim JustFolder As String

ShName = "inspection request" '<---- Change
Set Rng = Range("B3:B46") '<---- Change

'Select the files with GetOpenFilename
FileNameXls = Application.GetOpenFilename(FileFilter:="Excel files (*.xls), *.xls", MultiSelect:=True)

If IsArray(FileNameXls) = False Then
'do nothing
Else
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'Use this sheet for the Summary
Set SummWks = Sheets("log") '<---- Change

For FNum = LBound(FileNameXls) To UBound(FileNameXls)
ColNum = 1
RwNum = LastRow(SummWks) + 1
FinalSlash = InStrRev(FileNameXls(FNum), "")
JustFileName = Mid(FileNameXls(FNum), FinalSlash + 1)
JustFolder = Left(FileNameXls(FNum), FinalSlash - 1)

'If the workbook name already exist the row color will be Blue
Set fndFileName = Nothing
Set fndFileName = SummWks.Cells.Find(JustFileName)
If Not fndFileName Is Nothing Then
SummWks.Cells(RwNum, 1).Resize(1, Rng.Cells.Count + 1) _
.Interior.Color = vbGreen
Else
'Do nothing
End If

'copy the workbook name in column A
SummWks.Cells(RwNum, 1).Value = JustFileName

'build the formula string
JustFileName = WorksheetFunction.Substitute(JustFileName, "'", "''")
PathStr = "'" & JustFolder & "[" & JustFileName & "]" _
& ShName & "'!"

On Error Resume Next
SheetCheck = ExecuteExcel4Macro(PathStr & Range("A1") _
.Address(, , xlR1C1))
If Err.Number <> 0 Then
'If the sheet name not exist the row color will be Yellow.
SummWks.Cells(RwNum, 1).Resize(1, Rng.Cells.Count + 1) _
.Interior.Color = vbYellow
Else
'Insert the formulas
For Each myCell In Rng.Cells
ColNum = ColNum + 1
SummWks.Cells(RwNum, ColNum).Formula = "=" _
& PathStr & myCell.Address
Next myCell
End If
On Error GoTo 0
Next FNum

' Use AutoFit to set the column width
SummWks.UsedRange.Columns.AutoFit

With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End If
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

Hi all,

I need a big help..

I created a Macro Code and I need apply this code to all excel files in a folder, because I have approximately one thousand files.. Yes, true..

Open one to one, its impossible..

Please, Help me in this problem.
since now, thank you very much

Best regards,

I've got my vba/macro code running correctly in one workbook. What is the best way to add/attach that code to many workbooks? (Use a template?)

The code is linked to a button and I don't want to add the code and button manually to many workbooks.

Any ideas are greatly appreciated. Thank you.

I was able to download 3 files from 3.5 floppy disk once in excel format and
printed one file, but since then the system kept saying my disk needs format
or may be in MacIntosh.

I am relatively new to vba. This is a test macro to open access and close a workbook.
I am using Excel 2007 on win 7 & win xp

	VB:
	
 copyCount() 
    Dim wb As Workbook 
    Dim fname As String 
     
    Application.ScreenUpdating = False 
    fname = ActiveSheet.Name 
    Set wb = Workbooks.Open("C:UsersDeepakDocumentsOFFICEFixedValues.xlsx", True, True) 
     'With ActiveWorkbook.Worksheets("sheet1")
    With ThisWorkbook.Worksheets(fname) 
        .Range("A1").Value = wb.Worksheets("common").Range("A1").Value 
    End With 
    wb.Close False 
    Set wb = Nothing 
    Application.ScreenUpdating = True 
     
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
This works fine but i can only place the result in the WorkSheet that contains the macro.
To try and make it reusable i used the commented code line and also placed the macro in a Personal.xlsb file.
I get a Subscript Out of range error.
i would appriciate any help?

Hi All,

I have the below macro code (which I got from a extensive google search) which downloads the attachments from the emails from MS Outlook. I want to modify this macro in such a way that it looks the subject of the mail and only then tries to save the attachment of that mail, because right now this macro tries to download attachments of all mails which are present in a folder and apart from this it should rename the files as mentioned in a excel sheet for example. In a sheet I have the column A which contains some text which usually is a part of subject line and column B as the names which I want the macro to use as new names for the attachments downloaded from emails. Attached is my excel macro file for your reference.

Option Explicit


Sub GetAttachments()
' This Outlook macro checks a the Outlook Inbox for messages
' with attached files (of any type) and saves them to disk.
' NOTE: make sure the specified save folder exists before
' running the macro.
    On Error GoTo GetAttachments_err
' Declare variables
    Dim ns As NameSpace
    Dim Inbox As MAPIFolder
    Dim Item As Object
    Dim Atmt As Attachment
    Dim FileName As String
    Dim i As Integer
    Set ns = GetNamespace("MAPI")
    Set Inbox = ns.GetDefaultFolder(olFolderInbox)
    i = 0
' Check Inbox for messages and exit of none found
    If Inbox.Items.Count = 0 Then
        MsgBox "There are no messages in the Inbox.", vbInformation, _
               "Nothing Found"
        Exit Sub
    End If
' Check each message for attachments
    For Each Item In Inbox.Items
' Save any attachments found
        For Each Atmt In Item.Attachments
        ' This path must exist! Change folder name as necessary.
            FileName = "C:Email Attachments" & Atmt.FileName
            Atmt.SaveAsFile FileName
            i = i + 1
         Next Atmt
    Next Item
' Show summary message
    If i > 0 Then
        MsgBox "I found " & i & " attached files." _
        & vbCrLf & "I have saved them into the C:Email Attachments folder." _
        & vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
    Else
        MsgBox "I didn't find any attached files in your mail.", vbInformation, "Finished!"
    End If
' Clear memory
GetAttachments_exit:
    Set Atmt = Nothing
    Set Item = Nothing
    Set ns = Nothing
    Exit Sub
' Handle errors
GetAttachments_err:
    MsgBox "An unexpected error has occurred." _
        & vbCrLf & "Please note and report the following information." _
        & vbCrLf & "Macro Name: GetAttachments" _
        & vbCrLf & "Error Number: " & Err.Number _
        & vbCrLf & "Error Description: " & Err.Description _
        , vbCritical, "Error!"
    Resume GetAttachments_exit
End Sub

Sub SaveAttachmentsToFolder()
' This Outlook macro checks a named subfolder in the Outlook Inbox
' (here the "Sales Reports" folder) for messages with attached
' files of a specific type (here file with an "xls" extension)
' and saves them to disk. Saved files are timestamped. The user
' can choose to view the saved files in Windows Explorer.
' NOTE: make sure the specified subfolder and save folder exist
' before running the macro.
    On Error GoTo SaveAttachmentsToFolder_err
' Declare variables
    Dim ns As NameSpace
    Dim Inbox As MAPIFolder
    Dim SubFolder As MAPIFolder
    Dim Item As Object
    Dim Atmt As Attachment
    Dim FileName As String
    Dim i As Integer
    Dim varResponse As VbMsgBoxResult
    Set ns = GetNamespace("MAPI")
    Set Inbox = ns.GetDefaultFolder(olFolderInbox)
    Set SubFolder = Inbox.Folders("Sales Reports") ' Enter correct subfolder name.
    i = 0
' Check subfolder for messages and exit of none found
    If SubFolder.Items.Count = 0 Then
        MsgBox "There are no messages in the Sales Reports folder.", vbInformation, _
               "Nothing Found"
        Exit Sub
    End If
' Check each message for attachments
    For Each Item In SubFolder.Items
        For Each Atmt In Item.Attachments
' Check filename of each attachment and save if it has "xls" extension
            If Right(Atmt.FileName, 3) = "xls" Then
            ' This path must exist! Change folder name as necessary.
                FileName = "C:Email Attachments" & _
                    Format(Item.CreationTime, "yyyymmdd_hhnnss_") & Atmt.FileName
                Atmt.SaveAsFile FileName
                i = i + 1
            End If
        Next Atmt
    Next Item
' Show summary message
    If i > 0 Then
        varResponse = MsgBox("I found " & i & " attached files." _
        & vbCrLf & "I have saved them into the C:Email Attachments folder." _
        & vbCrLf & vbCrLf & "Would you like to view the files now?" _
        , vbQuestion + vbYesNo, "Finished!")
' Open Windows Explorer to display saved files if user chooses
        If varResponse = vbYes Then
            Shell "Explorer.exe /e,C:Email Attachments", vbNormalFocus
        End If
    Else
        MsgBox "I didn't find any attached files in your mail.", vbInformation, "Finished!"
    End If
' Clear memory
SaveAttachmentsToFolder_exit:
    Set Atmt = Nothing
    Set Item = Nothing
    Set ns = Nothing
    Exit Sub
' Handle Errors
SaveAttachmentsToFolder_err:
    MsgBox "An unexpected error has occurred." _
        & vbCrLf & "Please note and report the following information." _
        & vbCrLf & "Macro Name: GetAttachments" _
        & vbCrLf & "Error Number: " & Err.Number _
        & vbCrLf & "Error Description: " & Err.Description _
        , vbCritical, "Error!"
    Resume SaveAttachmentsToFolder_exit
End Sub


How can I download a changing file from a URL. This file has the .pdf extension and first is in a main file. What I want to do with Excel Macro is to pull all files from the Main URL and the content thereof?

Hi, I want to write a VBA macro in Word that open an Excel file, save that Excel file to another file (to another name), and then clear all content of the original Excel file. How to do that? Thanks!

I have an excel file open with a button on it, and when pressed, it prompts a open file box, and the user can then open the file (a word file), and all the tables (there are 3) are copied to specific cells in the excel sheet. However, now i added a button to the word document which pormpts save-as, and now the button on the excel file doesn't work and it gives me runtime error 57121.

My code is as follows

	VB:
	
 OpenExisting_Click() 
    Dim wdDoc As Object 
    Dim wdFileName As Variant 
    Dim y As Integer 
    Dim x As Integer 
    Dim t As Integer 
    Dim r As Integer 
    r = 1 
    y = 1 
    x = 2 
    wdFileName = Application.GetOpenFilename("Word files (*.doc),*.doc", , _ 
    "Browse for file containing table to be imported") 
    If wdFileName = False Then Exit Sub '(user cancelled import file browser)
    Set wdDoc = GetObject(wdFileName) 'open Word fileword.Visible = True
     
    With wdDoc 
        With .tables(1) 
             'copy cell contents from Word table cells to Excel cells
            Cells(1, 2) = WorksheetFunction.Clean(.cell(1, 3).Range.Text) 
        End With 
    End With 
    With wdDoc 
        With .tables(2) 
            For i = 1 To 5 
                Cells(x, 2) = WorksheetFunction.Clean(.cell(y, 2).Range.Text) 
                x = x + 1 
                y = y + 1 
            Next 
             
            y = 1 
            x = 2 
            For i = 1 To 4 
                Cells(x, 5) = WorksheetFunction.Clean(.cell(y, 4).Range.Text) 
                x = x + 1 
                y = y + 1 
            Next 
        End With 
    End With 
     
    With wdDoc 
        With .tables(3) 
            For iCol = 1 To .Columns.Count 
                t = 9 
                For iRow = 3 To .Rows.Count 
                    Cells(t, r) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text) 
                    t = t + 1 
                Next iRow 
                r = r + 1 
            Next iCol 
        End With 
    End With 
    Set wdDoc = Nothing 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
Does anyone know how to fix this problem?

Kempe

Is it possible to write a procedure to download a file from a site, then copy some fields from the downloaded file to my file?

Or if it isn't necessary just open the file automaticaly and copy the values.

Does someone knows the way to program this if possible?

Hi,

1. I require VBA code to overwrite excel file in destination folder if exist.

2.
Actually my macro code first sort,save and close the file, then it copy and paste this excel file to destiny network drive.

All things are working here except copy and paste. I am able to copy and then move file to destiny but I want to paste it and not move.
Help in this regard really appreciated

Good evening guys/girls,
I am new to the forum, and have tried to make the title of my thread as helpful as possible.
Right, I need some help writing a piece of Vba code, attached is the workbook I want to use this macro on.
I want to be able to create a macro that asks the question "What gap profile do you require", the answer I give will point it to which sheets to copy the information from.
For example, the question box pops up and asks what gap profile I want, I enter 0.3, and it copies Columns A and D from the sheet called "GAP 0.3" and pastes it in a new sheet called "SPC"...

I hope this is clear, any help will be appreciated

P.S: I can do the copy and paste bit, what I really need help with is the question box, along with IF statements that tell it what sheet to go to.

Thanks

Here is my basic code:

Workbooks.Open ("Hard Drive: BlankQuote.xls")

The file will not open and I absolutely, positively have the file located on the Hard Drive (no subfolder). I get an error that says:

"Error 1004: File BlankQuote.xls could not be found. Verify that the file exists and the location is correct, blah, blah"

I eventuallly need to access this file from a centralized server. But if I can't open the sucker from my local desktop, I am definitely SOL trying to get it from the server. Can anyone help with some pointers that I may be overlooking?

I have a custom save button that exports data to a .dat file. I have disabled the save button from the excel menu. Now I want to run the "SaveData" macro when the workbook is closed and not save the file before close. Below is my export code.


	VB:
	
 SaveData() 
    Dim mainCmdBar As CommandBar 
    Dim dnx As CommandBarPopup 
    Dim appBtn As CommandBarPopup 
    Dim expBtn As CommandBarControl 
    Dim i As Integer 
     
    Set mainCmdBar = Application.CommandBars.Item("Worksheet Menu Bar") 
    Set dnx = mainCmdBar.FindControl(, , "DoneEx_MainMenu_Item_Tag") 
    If Not dnx Is Nothing Then 
        For i = 1 To dnx.Controls.Count 
            If dnx.Controls.Item(i).Tag = "DoneEx_Package_Submenu" Then 
                Set appBtn = dnx.Controls.Item(i) 
                Exit For 
            End If 
        Next 
        If Not appBtn Is Nothing Then 
            Set expBtn = appBtn.Controls.Item(1) 
            If Not expBtn Is Nothing Then 
                If expBtn.Enabled Then 
                    expBtn.Execute 'save data
                End If 
            End If 
        End If 
    End If 
    Range("DateLastChanged") = Now() 
     
     
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines


Hello. I have an Excel macro which opens the Excel files, refreshes all contents, saves and closes them. When I launch the macro, the following prompt appears once:

Connect to Intranet
User name
Password

Remember my password

OK Cancel

How do I mimic the login/password entry in VBA to eliminate the need to interact with the prompt?

Thanks

PS: Below is a small fragment of the macro. The prompt starts when the macro tries to access the intranet file.

Application.WindowState = xlMinimized
Workbooks.Open Filename:= "http://intranet/sitesd/metrics/GrossProfits.xlsx"
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWorkbook.Close

How do I save a sheet from the macro workbook to a new file?

My code runs, the last thing I want to do it to move sheet named "Summary" to another work book, save it as XLS in the same directory as the macro, with the name being "Pivot Table" &myStartDate& myEndDate&".xls"

I'm under what to put after...

Sheets("Summary").Select
Sheets("Summary").Move

Thanks!

Hello forum,
I'm hoping someone will be able to help me with this. I am a novice and havent used loops in vba before. I suspect using a for/next loop will be the solution to the problem I am about to describe.

It's a bit of a convoluted problem, but the data output from the Macro needs to be entered in a certain format in order for it to be useful in the program I intend to use it in.

I have attached a spreadsheet of my data to make description easy:

What I'd like the Macro to do is:
1) Extract the entry from sheet 1 cell C2 and D2, then paste it in C1 and F1 on sheet 2 (respectively)
2) Extract the entry on sheet 1 cell E2 and F2 and paste it in C2 and F2 on sheet 2
3) Fill sheet 2 cell D1 and G1 with 3 (number) and D2 and G2 on the same sheet with 0 (number)
4) Fill sheet 2 cell H1 and H2 with -1 (number)
5) Fill sheet 2 A1 with the text string MPC
6) If the number in sheet 2 cell C1/F1 begin with 5, B1 etc should be 101, otherwise, it should be 102

A Sample of the (one) final entry for each line is shown in the sheet “sample”; basically, I want the code to repeat for all values in sheet 1 and stop

Any help will be appreciated.

Thanks


No luck finding an answer? You could always try Google.