Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 07-27-2018, 06:33 PM
kevinbradley57 kevinbradley57 is offline Convert range format to number Windows 7 64bit Convert range format to number Office 2010 64bit
Advanced Beginner
Convert range format to number
 
Join Date: Jul 2017
Posts: 89
kevinbradley57 is on a distinguished road
Default

I fixed the brackets. Now I get a Run-time error: Method 'Range' of object '_Global' failed.

Code:
 
Sub GetInProgress()
   Dim wb As Workbook, src As Workbook
   Dim sht As Worksheet, cel As Range
   Dim LR As Long
   
Set sht = ThisWorkbook.ActiveSheet
'remove existing data
With sht.UsedRange.Offset(1)
   .Borders.LineStyle = xlNone
   .ClearContents
End With
'see if source is open
For Each wb In Application.Workbooks
   If wb.Name = "SearchResultsInProgress " & Format(Date, "m.d.yy") & ".xls" Then
       Set src = wb
       Exit For
   End If
Next wb
'if yes copy data
If Not src Is Nothing Then
   src.Sheets(1).UsedRange.Offset(1).Copy
'if no display message and quit
Else
   MsgBox "Workbook   " & Chr(34) & "SearchResultsInProgress " & _
           Format(Date, "m.d.yy") & ".xls" & Chr(34) & "   is not open."
   Exit Sub
End If
'paste the copied data
With sht
   .Cells(2, 1).PasteSpecial (xlPasteValues)
   'name sheet
'  .Name = Left(src.Name, Len(src.Name) - 4)
   ' E from F if blank
  
   For Each cel In Intersect(.Columns("E"), .UsedRange)
       If cel.Value = "" Then cel.Value = cel.Offset(, 1).Value
   Next cel
   'position the cursor for sorting
      .Cells(2, 5).Select
   'determine last row
   LR = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

   With .Sort
       .SortFields.Clear
       .SortFields.Add Key:=Range("E2"), SortOn:=xlSortOnValues, Order:=xlAscending, _
                            DataOption:=xlSortTextAsNumbers
       .SetRange Range("A2:N" & LR)
       .Header = xlNo
       .MatchCase = False
       .Orientation = xlTopToBottom
       .SortMethod = xlPinYin
       .Apply
   End With
   
Range("K2:N").Select
    With Selection
        Selection.NumberFormat = "General"
        .Value = .Value
    End With
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert range format to number Format a range of cells Dave T Excel Programming 1 06-01-2016 08:58 PM
Convert range format to number How to format a TOC (level 1) using a number, but have the number hidden in the text porpoiseoil Word 1 09-13-2014 12:53 PM
IF statement - number range irhut Mail Merge 1 02-11-2014 11:20 PM
Change from General Format to number format gbaker Excel 3 08-16-2013 01:04 PM
Convert range format to number Cannot Convert Text Cell to number format to be able to sort the data jyfuller Excel 10 06-19-2013 05:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft