VBA Find keyword in cells and paste into Notepad

frkl

New Member
Joined
May 14, 2021
Messages
6
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Hello! :)

I have a scenario where the end-user clicks an activex button after they've finished entering values in the top part of the sheet. When the activex button is clicked it currently does this:

VBA Code:
Private Sub CommandButton5_Click()
Range("C8:C458").Copy
Shell "notepad.exe", vbNormalFocus
SendKeys "^V"
End Sub

This gets the job done (copies the range, opens notepad and pastes the range into notepad using sendkeys), but it's not what I want it to do exactly.

I would like it to copy some specific cells in the whole range (and those always stay the same, so they can be "hardcoded" by me later), while also I need it to search all the cells and copy all the ones that have the letters "bf" in them. These are the two criterias for searching, then I need the code to paste these mentioned cells in order from top to bottom into notepad like before.

Some of these cells in range C8:C458 contains plain text, others contain formulas such as in C35: =CONCAT("add ";C4;"") where the value of C4 sometimes will either have "bf" in it or be completely empty.

Please let me know if you need more information, I might've missed something :) I'm pretty new to VBA.

Thank you very much for your time and help.
Have a good day!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

frkl

New Member
Joined
May 14, 2021
Messages
6
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Bump! Anyone? :)
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,240
Office Version
  1. 2010
Platform
  1. Windows
Hi,​
as a more obvious way is to create a text file rather than 'piloting Notepad' so easier to help with an attachment of both files …​
 

frkl

New Member
Joined
May 14, 2021
Messages
6
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Hi,​
as a more obvious way is to create a text file rather than 'piloting Notepad' so easier to help with an attachment of both files …​
Alright. I'm open to suggestions. I might've explained my scenario poorly so I'll try again :D

I need something that only includes a cell in the range C8:C458 to be copied into notepad IF it meets the criteria below:

- has the letters "bf" in the cell
- has the word "commit" in the cell

Thanks in advance for your help, much appreciated
 

frkl

New Member
Joined
May 14, 2021
Messages
6
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows

ADVERTISEMENT

bump, please see my last post for a better description of what I'm actually looking for :)
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,240
Office Version
  1. 2010
Platform
  1. Windows
So read again post #3 but well this time …​
 

frkl

New Member
Joined
May 14, 2021
Messages
6
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows

ADVERTISEMENT

So read again post #3 but well this time …​
Yeah, I'm open to suggestions like I said :D How do I make vba create a text file that includes only the cells in the range C8:C458 that has either "bf" or "commit" in them? Thank you for your help
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,240
Office Version
  1. 2010
Platform
  1. Windows
If you do not know, as solution belongs to good enough readers so do what I expect in order to help like yet stated in post #3 !​
Or wait for some mind reader helper …​
 

frkl

New Member
Joined
May 14, 2021
Messages
6
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
If you do not know, as solution belongs to good enough readers so do what I expect in order to help like yet stated in post #3 !​
Or wait for some mind reader helper …​
I'm sorry, I've really tried to understand what you're saying in post #3. No need to get mad if I'm missing something :)

I thought you meant that it is possible for vba to create a text file and store the cell range (that meet the criteria I've mentioned a couple of times earlier), so therefor I stopped thinking about piloting Notepad like you said and instead I ask you how do I code vba to create a new .txt file then? Am I missing something else that is asked of me here? Please let me know if that's the case :)

I'm new to vba and coding in general, just hoped I could get some help on here :)
 

Forum statistics

Threads
1,141,308
Messages
5,705,666
Members
421,403
Latest member
cmowla

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
Top