Write a VBA module that has your program read 3 numbers from an excel spread she
ID: 3804304 • Letter: W
Question
Write a VBA module that has your program read 3 numbers from an excel spread sheet, etc. Can someone please show me in detail what to do.
Write out on Paper, then type code into VBA. Submit both. Write a VBA module/program/code (with a unique subroutine name) that a) Has your program read 3 numbers from an EXCEL spreadsheet. b) Use both the RANGE and CELLS commands at least once. c) One number will be a CONSTANT, one an INTEGER and one single variable. d) Your EXCEL spreadsheet has 1 cell that has the units. You read that into your program as a string variable. e) Your program then adds the 3 numbers and displays the answer and units in a message box and also on the spreadsheet.Explanation / Answer
Sub ParseText()
Dim sText As String, sFile As String
''Get the full path to the source file
With ThisWorkbook
sFile = .Names("SourcePath").RefersToRange
If Left(sFile, 1) <> "" Then sFile = sFile & ""
sFile = sFile & .Names("SourceFile").RefersToRange
End With
''Get the full text string from the text file
sText = GetText(sFile)
''Remove all nonprintable characters from the text
''Comment out if the characters are wanted
sText = Excel.WorksheetFunction.Clean(sText)
''Write to the workbook
WriteToSheet sText
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.