vba code to search google using cell content as search criteria [closed] - vba

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
firstly I can see that there is a vast amount of questions across multiple websites asking this same question, so please be patient with me as unfortunately the ones I have seen have either not been suitable or don't work and I am far from an expert.
to give you the full scenario - I have an xlsheet with a massive list of unique identifiers for products for the company I work for sells. I have to (at the moment) manually copy from the sheet to google to see its position in the results.
What would be great is to get a vba code that when I run it (hotkey it), automatically takes the cell contents and sends it into a google search so i effectively reduce my 3 clicks and ctrlV into one hotkey.

There's no need for VBA if all you want to do is open a Google search page one at a time.
With your search phrase in A1, use this formula, for example:
=HYPERLINK("http://www.google.com/search?q=" & A1,A1)
and fill down as far as required.
That will put a clickable link in column B, corresponding to the search phrase in column A.

Here is the code:
Sub Google_search()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate ("http://www.google.com/search?q=" & Cells(1, 1)) 'it will search for value, what is in column A1
IE.Visible = True
End Sub
Arrange the part Cells(1, 1) for the cell, what you really want to search.

Related

PasteSpecial not working - VBA [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to copy the data from one worksheet and paste it in another worksheet. But it is not working and asking me to use "A1" or R1C1. But I need to start the pasting from cell A5.
This is the code -
Range("A5:C9").PasteSpecial
Kindly share your thoughts. Thanks.
If you just need to paste the data from one worksheet to another, you can skip PasteSpecial (well, .Copy altogether) and just set the two ranges equal to another.
Worksheets("DESTworksheet").Range([DESTINATION range]).Value = Worksheets("ORIGINworksheet").Range([COPY range]).Value
So, try:
Worksheets("DestinationSheet").Range("A5:C9").Value = Worksheets("CopyFromSheet").Range("A5:C9").Value
Of course changing the worksheet names (and/or ranges) as necessary.

Excel VBA - If Then Replace [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am very new to VBA and I have read so much on the If-Then-Replace that I think I'm confusing myself. Within my worksheet I have two columns that come in with more data than what I need and I have to get it pared down in order to concatenate it.
Column H (Header) has the following data in each cell: Network: Series: Episode : Data
Column J (Header) has the following data in each cell: Network: Type: Type2: Type3
I run a text-to-columns to get it down to have the Network in 1 column and the Series in the 2nd column.
What I need is a Search in Column J for "specific network". If this is true then replace the network in Column H.
Question: Will I need to also run a text-to-columns in Column J to get a 1:1 comparison?
Question: Can you help me with the VBA code to do the Find-If-Then-Replace?
Thank you so much!
This should do what you're looking to do... If it works for you, please mark the answer as accepted by clicking the checkmark to the left.
Sub Freplace()
dim i as int
dim s as string
i = 1
s = "specific network"
Do until Cells(i,10).Value = ""
If Cells(i,10).Value = s Then Cells(i,8).Value = s
i = i+1
Loop
End Sub

Automatic excel cell fill up from another sheet [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Here's the situation:
I have two excel sheets.
The first sheet contains a table of product codes and product descriptions (Two columns A and B).
I have a second sheet where someone is supposed to enter the product code and automatically have the next cell fill up with the product description and the cell next to it with the time.
I was wondering if that's do-able without VBA? If so, can someone give me start.
Best,
You could have the first cell that you want to auto fill have an IF statement, where if the cell has no value, nothing happens, and anything other than that gets a calculation.
Using A2:B100 as a Range if you have a header Row. Adjust to your own needs, of course.
IF FUNCTION
'IF (condition, result if true, result if false)'
VLOOKUP FUNCTION
'VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)'
=If($A1 = "", "", VLOOKUP(A1,Sheet1!$A$2:$B$100,2))
The next cell over would have something similar:
=IF($A1 = "", "", NOW())
This will get you the time. You will also have to have the cell format set to Time.
There is a problem with that. The screenshot below illustrates it.
It will just keep refreshing with the current time over and over. I would use a bit of VBA to solve that by setting the value property instead of a formula.
Sheets("Sheet2").Cells(row,col).Value = Now()
You could copy and paste the value into another cell. Just the value. Not the formula.
Or you could check out this article: about generating Time Stamps.
edit: included VBA solution

search and highlight datas in vba [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm a beginner in VBA, I've been searching in the internet that could possibly help me get any ideas about my problem.But I can't find any result that is closely related to what I've been searching for, so I came here. I can't wrote any macro about this because I don't even know where to start.I have an excel as my database containing an ID number and a last name of a person. I want to create a macro that has an input box.If the value/text is found anywhere in the workbook the cell is highlighted in yellow. Any suggestions will be appreciated.
Thanks in advance.
If you can do without the input box and just enter your search text into a cell instead, I have a solution that involves no macros.
Just use conditional formatting instead. If the first cell of your data was say B2, highlight that cell and select conditional formatting from the ribbon menu, then New Rule followed by Use formula. In the format values enter the following:
=NOT(ISERROR(FIND($D$1,B2,1)))
Where B2 is you highlighted data cell and $D$1 is the cell where you are entering your search text. You can change the search cell location but must have the $$s.
Next hit the format button and change the fill color to yellow, then click OK.
All you then need to do is copy the format from the first data cell to the rest of the column.

Macro to Transfer Specific Table Content in MS Word 2007 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have around 50 word documents in an old format which I need to convert to a new format. I was thinking of having a new format template and copying needed numbered fields from the old format into the new format using a macro, and finally saving this new document.
I have numbered fields from 1 to 6 in the old format where some fields are in the header. I need these fields in the new format where the sequence is different.
I am a absolute beginner in macros and need to submit this tomorrow so would appreciate any help or advise urgently.
Word documents download links are mentioned below:
OLD FORMAT : http://www.scribd.com/R0cKyMan/d/90470134-Old-Format
NEW FORMAT : http://www.scribd.com/R0cKyMan/d/90473107-New-Format
So can u help me out with copy header fields. Thanks – R0cKy 3 mins ago
The tables in the Header have to be accessed in a different way.
When a table is in the body, you can use it like this
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Copy
But to access the table which is in the Header you have to access the Section in which the Header is. In your case the table is in wdHeaderFooterPrimary
Try this
Option Explicit
Sub Sample()
'~~> Copies the 2nd Cell in the first row of a table which is in the Header
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1, 2).Select
Selection.Copy
'~~> Pastes it in say 1st cell in Row 1 of a table which is in the body
ActiveDocument.Tables(1).Cell(2, 3).Select
Selection.PasteAndFormat (wdPasteDefault)
End Sub
Hope this gets you started.