4
Answers

How to create macro to browse a file and alter column?

Raja

Raja

8y
304
1
i need to browse file in the particular path and pick the file after that change the column.
Answers (4)
1
Madhanmohan Devarajan

Madhanmohan Devarajan

NA 6.5k 471.4k 8y
Raja,
 
First you need to open the excel sheet where you need to write macro. After that to add button you need to select "Developer" tab -> Insert Icon-> button  
 
 
Now it will show you a pop with click event for the newly added button. Copy and Paste the below code in the Editor.
 
// Button click event
Dim my_FileName As Variant
my_FileName = Application.GetOpenFilename(FileFilter:=”Excel Files,*.xl*;*.xm*”)
If my_FileName <> False Then
Workbooks.Open FileName:=my_FileName
End If
Note: The above code should be copied in the button click () event.
 
This only to show the File open dialog box on clicking the button.  
 
You need to create function for deleting the columns in the sas production details.xlsx using below macro.
 
Sub Macro1()
'
' Macro1 Macro
'
'
Range("B1").Select
Range(Selection, Selection.End(xlDown)).Select
Columns("B:B").Select
Application.CutCopyMode = False
Selection.ClearContents
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
End Sub
 
 You have to change the macro according to your need. Hope it will be helpful for you.
Accepted
1
Madhanmohan Devarajan

Madhanmohan Devarajan

NA 6.5k 471.4k 8y
Raja,
 
Please be specific about the requirement.
 
1. Are you having list of filenames in Excel sheet?
2. Are you trying to open the files one after the other from the list in Excel?
3. After completing the process with one file you are going to change the color of the filename (cell) in the list to mark it as "File already visited"?
 
Please answer all the above queries, so that it will be easy for me to understand your requirement and to provide solution. 
0
Raja

Raja

NA 1.7k 45.4k 8y

Madhanmohan Devarajan

sorry for late reply sir.
 
Thank you so much!
0
Raja

Raja

NA 1.7k 45.4k 8y
hi,
 
i expect that the excel sheet has set one click option
 
after that i click that option it shows browse a file option in computer.
 
ex : E:\software\DRIVER\driver
 
now i will select the file name sas production details.xlsx 
 
select the file and click ok
 
need to re order the column if i have the a to z column then i need to set
like b,f,g,h,d,l and delect the other column