Programmer's Notes

I'm not quite seeing it yet. If you had following code you wanted to save that is in Sheet1 VBA editor for currently open workbook, how would you go about saving it to a file with a name of "Ranges01"

Code:
Sub RangeExample()
    Range("A1").Select
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
In the Project Explorer window, you can see a list of modules in the VBA project. Grab any module with your mouse and drag it to the desktop, or to any open file browser window.
 
I see. That might be an easier way to move code around if they are in specific files or functions ready to go. Using a .bas format. I'll play around with it some.

Thanks.
 
use something like this - you can set your CurrentPath to what you want - also change the file name to wat you wnat

Code:
Dim NewBookX As Workbook
Set NewBookX = Workbooks.Add
 
 On Error Resume Next
    NewBookX.SaveAs Filename:=CurrentPath & "\" & "WhateverNameYouWant.xlsx"
    If Err.Number <> 0 Then
        ActiveWorkbook.Close    ' closes the active workbook and lets the user decide if changes are to be saved or not
    Else
        ActiveWorkbook.Close False    ' closes the active workbook without saving any changes
       'ActiveWorkbook.Close True    ' closes the active workbook and saves any changes
    End If
 
ohhh insert a

err.Clear

after the 'on error resume next' - just in case
 
schielrn (or anyone else) -

I like your comment: "I also have at least 50-100 text files of different code snippets that I can throw into any program and adapt them."
I basically have all of mine stored on our network drive at work and also on my flash drive.

They are in a common folder on the netword drive that anyone can access and people go there to pull different things.

I try to have dscriptive names of the files, like I have for instance:

SeparateTabsbyAutoFilter.txt
SeparateTabsbyArray.txt
SeparateTabsbyArrayFasterVersion.txt
SeparateTabsbyArrayMuchFasterVersion.txt

They do the same thing just in a little different way. And I can probably delete some of the slower ones ;). But inside of each text file I have built a comment section at the top that goes more into detail of what this particular program actually does.

Then they can just open the text file and drop it into a standard module.

If it is a procedure that might need other functions/subs like getdirectory() I have included those in those text files.

I do have some exported whole modules and userforms as well within there.

Hope that helps explain how I do it at least.
 
I build small working samples of workbooks / databases, then show them in a resource directory.

When I get around to it I write stuff for my website -- instant access ;-) but the trick is to remember to update when I come across a new tip / technique.

Denis
 
schielrn - I like the idea of your directory being .txt files. So easy to carry around (flash drives etc) and others can use them too.

Wondering what .txt editor you are using? To actually create the exported code? Am assuming then you just copy and paste from opened .txt files instead of import?

I am starting to collect and write a lot of code that I need to organize better. Still trying to decide which route to go.

Thanks.

Chuck
 
I like the idea of your directory being .txt files
.bas files -- what you export a module as -- are text files.
 

Forum statistics

Threads
1,222,626
Messages
6,167,157
Members
452,099
Latest member
Auroraaa

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