|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Opposite of IsEmpty??
Hi,
Can someone help make this macro go the the next cell that isNOTempty? Thanks Sub CpySrchPhraseFromSsAndPasteToSearchEngine() ' ' CpySrchPhraseFromSsAndPasteToSearchEngine Macro Dim Download As Range, Cell As Object Set Download = Sheets("searchwords.0(1)").Range("A2:A101") 'Range containing search words For Each Cell In Download If IsEmpty(Cell) Then 'end loop if cell is empty Exit Sub 'Would rather have this macro GO TO THE NEXT NONBLANK CELL instead of exiting sub Else Selection.Copy MsgBox "Go search engine and Paste" Selection.Offset(1, 0).Select End If Next End Sub |
|
#2
|
|||
|
|||
|
Might try:
Code:
If Not IsEmpty(Cell) Then
Selection.Copy
MsgBox "Go search engine and Paste"
Selection.Offset(1, 0).Select
End If
|
|
#3
|
|||
|
|||
|
Thanks, June7.
For some reason, it still copies the blank cells (maybe the offset 1,0 takes precedence over the Not Isempty?).... Is there a way to write "if Isempty, then go copy the next Not Isempty"? |
|
#4
|
|||
|
|||
|
'Fraid I didn't look at your code inside the IF THEN, sorry, and haven't been doing much coding for Excel lately. Now that I think about it, I have used ISBLANK not ISEMPTY. Maybe I need to know more about what you want to do. Why use the Select at all? Don't have to actually select a cell to grab its contents. Refer to cells with the Cells property or Range object. Excel VBA help has pretty good info on this.
|
|
#5
|
|||
|
|||
|
My vision for this macro is actually in 2 parts:
What I'm attempting to do 1st is to automatically copy--1 by 1--each of 100 search terms in range A2:A101 of my spreadsheet (Health.xlsx), and paste each one to http://www.google.com/ and search for it. The 2nd part will be more difficult. Once google finds the results for a search, I'd like to copy the number of search results and paste that number to column P of that seach term's row. (It can be copied either from the webpage or from the source page--whichever one is doable). |
|
#6
|
|||
|
|||
|
You want to do 100 searches? Since you have known range, I would do something like:
Code:
For i = 2 to 101
strSearch = Sheets("searchwords.0(1)").Cells(i, 1).Value
If Len(strSearch) > 0 Then
'code to paste strSearch to google
'code to paste results to column
End If
Next
|
|
#7
|
|||
|
|||
|
Thank you (works just as well as the first one, and is shorter).
Can anyone help me to get this code to work (it just goes to the code and highlights "Stop"): Option Explicit |
|
#8
|
|||
|
|||
|
Should view this link on the Stop statement
http://msdn.microsoft.com/en-us/lib...y2f(VS.80).aspx Excerpt: "The Visual Basic Stop statement provides a programmatic alternative to setting a breakpoint." |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Opposite of IsEmpty?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|