Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 23rd, 2009, 02:32 PM
Turk182 Turk182 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 17 Turk182 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 11 m 40 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old October 23rd, 2009, 05:39 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
Might try:

Code:
If Not IsEmpty(Cell) Then
    Selection.Copy
    MsgBox "Go search engine and Paste"
    Selection.Offset(1, 0).Select
End If

Reply With Quote
  #3  
Old October 23rd, 2009, 11:05 PM
Turk182 Turk182 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 17 Turk182 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 11 m 40 sec
Reputation Power: 0
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"?

Reply With Quote
  #4  
Old October 24th, 2009, 02:55 AM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
'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.

Reply With Quote
  #5  
Old October 24th, 2009, 10:32 AM
Turk182 Turk182 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 17 Turk182 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 11 m 40 sec
Reputation Power: 0
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).

Reply With Quote
  #6  
Old October 24th, 2009, 02:52 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
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

Reply With Quote
  #7  
Old October 31st, 2009, 10:31 PM
Turk182 Turk182 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 17 Turk182 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 11 m 40 sec
Reputation Power: 0
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

Sub getWebPageDocument()

Dim objHtmlDoc As New MSHTML.HTMLDocument
Dim myHtmlDoc As MSHTML.HTMLDocument

Set myHtmlDoc = objHtmlDoc.createDocumentFromUrl("http://www.nasdaq.com/aspxcontent/ExtendedTradingTrades.aspx?selected=ALTH&mkttype=after", vbNullString)

While myHtmlDoc.readyState <> "complete"
DoEvents
Wend

Debug.Print myHtmlDoc.body.innerHTML

Stop

End Sub

Reply With Quote
  #8  
Old October 31st, 2009, 11:33 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
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."

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Opposite of IsEmpty??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek