Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi: Excel2003. I have a list of file names in column A (340 rows). I want to
copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, ..lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Give this macro a try...
Sub GetExtensions() Dim X As Long Dim LastRow As Long Dim FName As String With Worksheets("Sheet3") LastRow = Worksheets("Sheet3").Cells(.Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow FName = .Cells(X, "A").Value .Cells(X, "B").Value = Mid(FName, InStrRev(FName, ".") + 1) Next End With End Sub -- Rick (MVP - Excel) "StephCA" wrote in message ... Hi: Excel2003. I have a list of file names in column A (340 rows). I want to copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, .lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rick, this was perfect. Thanks! One question: I'll always be running this on
the active worksheet. How can I specify the "active" sheet where you show "sheet3" in the code. TIA again, Stephanie "Rick Rothstein" wrote: Give this macro a try... Sub GetExtensions() Dim X As Long Dim LastRow As Long Dim FName As String With Worksheets("Sheet3") LastRow = Worksheets("Sheet3").Cells(.Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow FName = .Cells(X, "A").Value .Cells(X, "B").Value = Mid(FName, InStrRev(FName, ".") + 1) Next End With End Sub -- Rick (MVP - Excel) "StephCA" wrote in message ... Hi: Excel2003. I have a list of file names in column A (340 rows). I want to copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, .lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this...
Sub GetExtensions() Dim X As Long Dim LastRow As Long Dim FName As String With ActiveSheet LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow FName = .Cells(X, "A").Value .Cells(X, "B").Value = Mid(FName, InStrRev(FName, ".") + 1) Next End With End Sub -- Rick (MVP - Excel) "StephCA" wrote in message ... Rick, this was perfect. Thanks! One question: I'll always be running this on the active worksheet. How can I specify the "active" sheet where you show "sheet3" in the code. TIA again, Stephanie "Rick Rothstein" wrote: Give this macro a try... Sub GetExtensions() Dim X As Long Dim LastRow As Long Dim FName As String With Worksheets("Sheet3") LastRow = Worksheets("Sheet3").Cells(.Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow FName = .Cells(X, "A").Value .Cells(X, "B").Value = Mid(FName, InStrRev(FName, ".") + 1) Next End With End Sub -- Rick (MVP - Excel) "StephCA" wrote in message ... Hi: Excel2003. I have a list of file names in column A (340 rows). I want to copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, .lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For the archives... I left an extra reference to the worksheet inside the
With block (doesn't really hurt anything in the end, but it was unnecessary). This is the code as it should have been posted... Sub GetExtensions() Dim X As Long Dim LastRow As Long Dim FName As String With Worksheets("Sheet3") LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow FName = .Cells(X, "A").Value .Cells(X, "B").Value = Mid(FName, InStrRev(FName, ".") + 1) Next End With End Sub -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... Give this macro a try... Sub GetExtensions() Dim X As Long Dim LastRow As Long Dim FName As String With Worksheets("Sheet3") LastRow = Worksheets("Sheet3").Cells(.Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow FName = .Cells(X, "A").Value .Cells(X, "B").Value = Mid(FName, InStrRev(FName, ".") + 1) Next End With End Sub -- Rick (MVP - Excel) "StephCA" wrote in message ... Hi: Excel2003. I have a list of file names in column A (340 rows). I want to copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, .lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you want VBA?
You could do the same with DataText to ColumnsDelimited by a period. Gord Dibben MS Excel MVP On Fri, 3 Oct 2008 16:26:00 -0700, StephCA wrote: Hi: Excel2003. I have a list of file names in column A (340 rows). I want to copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, .lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes. Needed VBA to add to an already written macro. And Rick's code is very
quick! Didn't know DataText, though. Thanks much for the tip. Stephanie "Gord Dibben" wrote: Do you want VBA? You could do the same with DataText to ColumnsDelimited by a period. Gord Dibben MS Excel MVP On Fri, 3 Oct 2008 16:26:00 -0700, StephCA wrote: Hi: Excel2003. I have a list of file names in column A (340 rows). I want to copy the extension (only) from each name in col A to col B -- so I can sort the worksheet by file extension. There are about 15 extensions (.xls, .doc, .lnk etc.) Can someone provide me the VBA code, or a starting point, to do this? TIA, Stephanie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Determine Excel file version with no file extension. | Excel Discussion (Misc queries) | |||
file format or file extension is not valid...error message | Excel Discussion (Misc queries) | |||
Additional file with no extension created during File Save As proc | Excel Discussion (Misc queries) | |||
Saving two file names? One with no extension? | Excel Programming | |||
I need to download an exel spreadsheet file. (file extension :xls) | Excel Discussion (Misc queries) |