So currently I have a code that when I hit the button, it will automatically bring up the save as screen (to csv) where I can type in the filename and hit save and its done.
what I want to happen on a separate button is the same thing, however, I want it to save the selection with only the values keeping the format(background colors etcs) as another excel workbook, AND grab the filename from a specific cell.
ive have tried different codes and macros and for the life of me cant get it to work. but this code here does what I want for CSV....but I basically just need to modify this code to do what I need for the Xlsx file...which I cant get it to do...please help
what I want to happen on a separate button is the same thing, however, I want it to save the selection with only the values keeping the format(background colors etcs) as another excel workbook, AND grab the filename from a specific cell.
Sub CSVFile()
Dim SrcRg As Range
Dim CurrRow As Range
Dim CurrCell As Range
Dim CurrTextStr As String
Dim ListSep As String
Dim FName As Variant
FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
ListSep = Application.International(xlListSeparator)
If Selection.Cells.Count > 1 Then
Set SrcRg = Selection
Else
Set SrcRg = ActiveSheet.UsedRange
End If
Open FName For Output As #1
For Each CurrRow In SrcRg.Rows
CurrTextStr = ìî
For Each CurrCell In CurrRow.Cells
If IsNumeric(CurrCell.Value) Then
CurrTextStr = CurrTextStr & CurrCell.Value & ListSep
Else
CurrTextStr = CurrTextStr & "" & CurrCell.Value & "" & ListSep
End If
Next
While Right(CurrTextStr, 1) = ListSep
CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
Wend
Print #1, CurrTextStr
Next
Close #1
End Sub
ive have tried different codes and macros and for the life of me cant get it to work. but this code here does what I want for CSV....but I basically just need to modify this code to do what I need for the Xlsx file...which I cant get it to do...please help