VBA Code to working properly

fari1

Active Member
Joined
May 29, 2011
Messages
362
i've a code, that cuts and paste the first used cell from the column A, this works fine when run individually, but when its the part of the loop, it stops somewhere in the middle and then dont cut and paste the first used cell, it just dont give any resullts


Code:
Sub usedsymbols()
Dim mycell As Range
Application.CutCopyMode = True
Sheets("symbols").Select
With Sheets("symbols")
With .Columns("A")
.Find(what:="*", after:=.Cells(1, 1), LookIn:=xlValues).Activate
Set mycell = ActiveCell
mycell.Cut Sheets("Log").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
End With
Application.CutCopyMode = False
End Sub

ANY HELP WOULD BE HIGHLY APPRECIATED
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Then you should post the code of the loop.
 
Upvote 0
Okay, just give me some time, i've already run the loop, when it'll stop, i'll post the code
 
Upvote 0
Okay, just give me some time, i've already run the loop, when it'll stop, i'll post the code

Does not seem very promising with regard to the code... How long do you expect it to take? How big is the loop?
 
Upvote 0
actually, the loop connects symbols via web query, and for each symbol there can even 10 or more URLs that again get connect to web query separately, so for my system resources one symbol takes min 6 min and i've run 7 symbols:(
 
Upvote 0
this code comes right before the usedsymbole code

Code:
Sub ooData()
    Dim wsInput As Worksheet, wsOutput As Worksheet
    Dim wsInputLRw As Long, i As Long
    Dim RngSource As Range
    
    On Error GoTo Whoa
    
    Application.ScreenUpdating = False
    
    Set wsInput = Sheets("info")
    Set wsOutput = Sheets("prof")
    
    wsInputLRw = wsInput.Range("A" & Rows.Count).End(xlUp).Row
    
    For i = 6 To wsInputLRw
        Select Case UCase(wsInput.Range("A" & i).Value)
        Case "10-K", "10-Q", "10-K/A", "10-Q/A"
            If RngSource Is Nothing Then
                Set RngSource = wsInput.Range("A" & i)
            Else
                Set RngSource = Union(RngSource, wsInput.Range("A" & i))
            End If
        End Select
    Next i
    
    If Not RngSource Is Nothing Then _
    RngSource.Copy wsOutput.Range("A13")
LetsContinue:
    Application.ScreenUpdating = True
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume LetsContinue
End Sub

and this comes after it


Code:
Sub infocopy2()
Sheets("filter").Range("G1:G9").Copy
Sheets("prof").Range("B1").PasteSpecial Paste:=xlPasteValues
End Sub
 
Upvote 0
- where does the code in the original question fit into these last procedures?

- I think that you misinterpret your loop. ooData should in fact just be an Advanced Filter (or Autofilter if you are on Excel 2007 and up).
 
Upvote 0
i guess i sorted out, the code is deleting the cells and loop is taking those cells into account, thata y giving problems, has to think of some other way around. thanks for your help anyways wigi
 
Upvote 0
i guess i sorted out, the code is deleting the cells and loop is taking those cells into account, thata y giving problems, has to think of some other way around. thanks for your help anyways wigi

That's why I suggested a filter approach, and throw out the loop.

If you DO want to loop, however, loop backwards (from "last" row to "first" row).
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top