Rename Any Kind of File In Specific Part Using Excel Macro - vba

My Question is I have a folder with a name "xyz" somewhere, for example it is on desktop and there are 2 excel files namely a,b in that xyz folder. I work in excel workbook "a" which consist of two names i,j in some cell values for example i is in cellA1, j is in A2.
Now I want to rename excel files a,b with i,j with of without opening or closing files after renaming. It is possible. If possible please post me the code. I have no code....please provide from scratch

I think you will find the answer by a simple search of previous questions. I easily found this which should get you on the right path:
Renaming files with vba

Related

Preserve settings in the file

I am creating my excel add-in that saves the current file as csv into user-specified folder. I would like my program to ask for the folder path the first time the program is launched and to remember that folder in the future. I am wondering is there any way to preserve the data within the program? I figured that I could write the path into .txt-file but that feels a little hack-like solution and would clutter the addin folder.
I use the GetSetting and SaveSetting functions in my VB 6 apps. Rather than cover them in detail, take a look at this excellent web page that illustrates how to use in with Excel
Excel Tips From John Walkenbach
Create a Worksheet, and store the values in cells. Then in the VBA Editor find the Worksheet in the Project Explorer (Ctrl + R) and set "Visible" to "2 - xlSheetVeryHidden" in the Properties Pane (F4) so that it is not readily visible to users.
You can then set/retrieve the data in with code in the format SheetName.Cells(row,column).Value, e.g.
MyPath = Sheet1.Cells(1,2).Value 'Get data from cell B1
Sheet1.Cells(2,2).Value = NewPath 'Set data in cell B2
There are multiple ways to approach this. Besides the hidden sheet approach, already described, you can
Write the information to a CustomXMLPart. This is a xml file stored in the workbook's ZIP file where information can be stored.
For something as short and simple as a file path, you could also use a CustomDocumentProperty

Import Many Text Files into Single Excel Sheet: One Per Row, Filename in Col. A, Contents in B

I would like to import multiple text files into a single Excel 2016 worksheet. The name of the first text file should go into cell A1, the name of the second text file should go into A2, and so forth. The contents of the first text file should go into cell B1, the contents of the second text file should go into B2, and so forth. What scripting tool or procedure should I use?
Use a vb Script to do this.
I recommend to record bits of what you need to do and learn from the generated code to write what you need.
You will need a VB function that lists files from a directory. Find some useful tips from https://blogs.technet.microsoft.com/heyscriptingguy/2004/10/20/how-can-i-get-a-list-of-all-the-files-in-a-folder-and-its-subfolders/ for this.
You will need a way to import the text files in excel. For this have a look at Vbscript to import csv into excel

Read formatted text file from excel with VBA

I have a huge text file with lots of numbers divided into different sections and I want to extract only certain values. It is something like this
step 1
787268 4.29430E-01
787269 4.05248E-01
787270 3.99742E-01
787271 3.99136E-01
787272 3.98422E-01
787273 3.97019E-01
787274 3.95237E-01
step 2
787268 4.29430E-01
787269 4.05248E-01
787270 3.99742E-01
787271 3.99136E-01
787272 3.98422E-01
787273 3.97019E-01
787274 3.95237E-01
I want to copy into my excel file only the two columns in the step 2 section.
So I need a VBA code that allows me to search for a particular string and after it finds it copy and paste all the raws until the next step.
Any pieces of code?
Thanks
Stefano
You can use this website to help you find what you need, a simple Google search can go a long way.
I would suggest using an if found section to find the spot where you need to copy over.
Ex.
If (Range("A1").Value = "YOUR TEXT HERE") Then
'''' COPY OVER DATA
End If

copying worksheet values from one workbook to another vb.net without formula links

Using vb.net. we want to copy several worksheets from one file into another file. we have it looping and copying which ones we have going by
xlWorksheetSource.Copy(After:=xlWorkbookDestination.Worksheets(xlWorkbookDestination.Worksheets.Count))
for example... but i noticed when i open up the file that was created.. in some of the columns it has links that reference the original file for formulas... how can you just have it so it copies the values and doesn't reference the original file in formulas that it copied.
You probably need to do something like this
xlWorksheetSource.PasteSpecial(xlPasteValues, xlPasteSpecialOperationNone, False, False)
For more information use this link:
ExcelPasteSpecial

excel macro to read text file and find matches in cells

I really could use some help
I have two .txt/csv files that I need to read from into my excel file.
In my excel file I have a whole column, each cell containing string of characters and I need to write a script to be able find matches and and copy an adjacent column from that txt file.
An example of a single row on my txt file is shown below:
"AB101AA","AB10 1AA","AB101A","AB10 1A","AB101","AB10 1","AB10","AB10","AB","10",394251,806376,,
"AB101AF","AB10 1AF","ABERDEEN","ABERDEENSHIRE",,"ABERDEEN, CITY OF"
My excel file would have a cell which probably say "AB101AF" and i want the corresponding cell to run through a million rows and find the match and then find the corresponding nth cell on the txt file and return it on the excel spreadsheet example "ABERDEEN, CITY OF".
I know I havent been helpful in explaining the issue. But any help would be appreciated.
Thank you
Depending upon the size of your text file you could import the file using the GetExternalData option in Excel. This would allow you to load your data into a different Sheet and then use a lookup to your data from the main Sheet. Using Match and/or vlookup should help here.
You could also add a workbook connection to the text file and search using the connection.