Question

ASAP. I need VBA code, for Excel please 5. Create text file with notepad. Each line...

ASAP. I need VBA code, for Excel please

5. Create text file with notepad. Each line contains only one word. Open it and,
if the word begins with capital letter, output it to column A, otherwise in
column B.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

VBA Code

Sub checkFirstLatter()
Dim Filepath As String 'this variable stores the file path
Filepath = "words.txt" 'here is the full path of your file (here my vba file and txt file are in same so only giving file name)
Dim strFirstChar As String 'this string variable stores the first char of word
Dim intASCII As Integer 'intger variable store the ascii value of char
  
Open Filepath For Input As #1 'open the file
rowANumber = 1
rowBNumber = 1
  
Do Until EOF(1) 'loop untill the End of file
Line Input #1, wordFromFile 'read the line and store in the wordFromFile variable
strFirstChar = Left$(wordFromFile, 1) 'extract the first char from the wordFromFile and store in the strFirstChar
intASCII = Asc(strFirstChar) 'gets the ascii value of that char
Select Case intASCII 'using case
Case 65 To 90 'ASCII Code for A to Z
Cells(rowANumber, 1).Value = wordFromFile
rowANumber = rowANumber + 1
Case Else
Cells(rowBNumber, 2).Value = wordFromFile
rowBNumber = rowBNumber + 1
End Select
Loop
Close #1
End Sub


Text file with words

output

Code snaps

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
ASAP. I need VBA code, for Excel please 5. Create text file with notepad. Each line...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need this problem to be solved in Excel VBA code. Need full code in VBA....

    I need this problem to be solved in Excel VBA code. Need full code in VBA. Please solve 1st Task : '5 or 0'. Please help me urgently with proper answer and coding solutions which I can run in Excel/vba. Thanks Course: Programming languages Second laboratory work File and string processing Create a program that processes text file according to task variant. Requirements: 1. Create text file (use notepad) with some lines of data according to task variant. 2. Ask...

  • Create a text file named “file1.txt” (by use of the notepad editor in Windows for instance)...

    Create a text file named “file1.txt” (by use of the notepad editor in Windows for instance) containing the following integer values, one per line: ​12 5 13 56 90 52 82 52 Write a Java program that reads these values from the file and displays their sum on the screen.

  • Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And...

    Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And also I have codes but just donot work so make sure that it works. Requested files: CrosswordGenerator.cpp, CrosswordGenerator.h, CrosswordGenerator_test.cpp CrosswordGenerator - Write a program that helps to generate a crossword puzzle by organizing words that share letters.   For this assignment, you will write a program that forms the basis of a crossword puzzle generator. In order to create a crossword puzzle you need to...

  • Visual Basic - I need to make a program to search a text file that is...

    Visual Basic - I need to make a program to search a text file that is in the debug. Found from "IO.File.ReadAllLines".  When the word is typed into a textbox and button pressed, the program should show which line the word first appeared in the text through a message box or another feature. If it is not found, the program will open a message box. I don't have the full code, please assist

  • Create a python code named LetterCount with a text file named words.txt that contains at least...

    Create a python code named LetterCount with a text file named words.txt that contains at least 100 words in any format - some words on the same line, some alone (this program involves no writing so you should not be erasing this file). Then create a program in the main.py that prompts the user for a file name then iterates through all the letters in words.txt, counting the frequency of each letter, and then printing those numbers at the end...

  • In python Count the frequency of each word in a text file. Let the user choose...

    In python Count the frequency of each word in a text file. Let the user choose a filename to read. 1. The program will count the frequency with which each word appears in the text. 2. Words which are the spelled the same but differ by case will be combined. 3. Punctuation should be removed 4. If the file does not exist, use a ‘try-execption’ block to handle the error 5. Output will list the words alphabetically, with the word...

  • python Create a program to open a text file for reading, find the maximum number in...

    python Create a program to open a text file for reading, find the maximum number in the file, determine if that maximum number is even, and write to an output text file. You should either write Yes if the number is even, otherwise write the maximum number. You should note the following: • Your input file must be named input.txt • The input file has one integer number per line • Your output file must be named output.txt • Your...

  • JAVA Code: Complete the program that reads from a text file and counts the occurrence of...

    JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...

  • C++ Can someone please help me with this problem- commenting each line of code so I...

    C++ Can someone please help me with this problem- commenting each line of code so I can understand how to solve this problem using the C++ programming language? I really need help understanding how to create a file for the program to read. Do I create the file in Visual basic or create a text file? I have the code, just need to know how to create the file for it to read. #include<fstream> #include<iostream> using namespace std; int main()...

  • C#: Create a file that contains your favorite movie quote. Use a text editor such as...

    C#: Create a file that contains your favorite movie quote. Use a text editor such as Notepad and save the file as Quote.txt. Copy the file contents and paste them into a word-processing program such as Word. Save the file as Quote.doc. Write console application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a file's size, you can create a System.IO.FileInfo object using a statement such as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT