• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need help organizing Excel files [SOLVED]

I

ijcedron

Guest
Hello,


I am looking for help to solve a currently hard-to-manage and hard-to-search pile of excel files.


A file contains details about special offers we have, ie: offer code, name of offer, effective date, expiration date, amount of offer, etc.

We issue about 10 of these every week to the staff via email, in forms of attachments.


When we have to search for something, we have to look through the printed offers, or open up several emails until we find what we're looking for. Lots of time wasted...


I'd like to set up a master Excel file where the offers can be ENTERED in a consistent and clean way, using pull down menus, etc., and which can be SEARCHED by a keyword or a partial keyword. I don't know where or how to begin this.


Does anyone have any suggestions or templates that I could customize?

Thank you very much, in advance.

Fern.
 
Hi Fern ,


As I see it , you have a system at present which does the following :


1. Data entry into a file


2. Transmittal of the files via email


I do not know how much of the above is already automated ; however , if you do decide to maintain a master file , you will still need to take care of point #2 above , since every email attachment will need an extraction of selected data from the master file.


If you ask me , selecting and extracting data is more difficult than just transferring entered data into a master file ; what I suggest is that you retain your existing files , and each time a record is entered , copy this to the master so that the master file is always up-to-date. Any searching that you need to do can be done on the master file.


The only point against this approach is that every individual file into which data is entered , and which is emailed needs to have the macro for transferring the newly entered record to the master , but this merely involves opening the master , and appending data to it , and can be simple.


Narayan
 
Hi Narayan,

This sounds a little too complicated for me, but I'll think it through.

I really appreciate your suggestions and time.

Thanks,

Fern.
 
Hi, Fern Jones!


Here's my Frankenstein (yesterday I watched on TV Young Frankenstein with & by Mel Brooks, so the name applies).


With pieces of a couple of posts I came up with this file:

https://dl.dropboxusercontent.com/u/60558749/Need%20help%20organizing%20Excel%20files%20%28for%20Fern%20Jones%20at%20chandoo.org%29.xlsm


1st worksheet: Master

- with a dynamic named range MasterTable

- with 2 command buttons, one for filling the 2nd worksheet and another for resetting filters


2nd worksheet: Filtered

- with a dynamic named range FilteredTable

- with 2 command buttons, one for viewing mails from 3rd worksheet and another for sending mails


3rd worksheet: Mail

- with a dynamic named range MailTable

This the code:

-----

Option Explicit

' constants
Const gksWSMaster = "Master"
Const gksMaster = "MasterTable"
Const gksWSFiltered = "Filtered"
Const gksFiltered = "FilteredTable"
Const gksWSMail = "Mail"
Const gksMail = "MailTable"
Const gksSeparator = " - "
Const gksWBOffer = "Offer_"
Const gksWBOfferExtension = ".xlsx"

' declarations
Dim grngMaster As Range, grngFiltered As Range, grngMail As Range
Dim gsOffer As String, gsWBOffer As String, gdOffer As Date

Sub CreateFiltered()
' constants
' declarations
Dim rw As Range
Dim lFiltered As Long
Dim I As Long, J As Integer
' start
Set grngMaster = Worksheets(gksWSMaster).Range(gksMaster)
Set grngFiltered = Worksheets(gksWSFiltered).Range(gksFiltered)
With grngFiltered
If .Rows.Count > 1 Then Range(.Rows(2), .Rows(.Rows.Count)).ClearContents
End With
lFiltered = 1
' process
With grngMaster.SpecialCells(xlCellTypeVisible)
For Each rw In .Rows
If rw.Row <> 1 Then
lFiltered = lFiltered + 1
For J = 1 To rw.Columns.Count
grngFiltered.Cells(lFiltered, J).Value = .Cells(rw.Row, J).Value
Next J
End If
Next rw
End With
BuildOfferText
BuildOfferWorkbook
' end
Set grngMaster = Nothing
Beep
End Sub

Private Sub BuildOfferText()
' constants
' declarations
Dim I As Long
' start
gsOffer = ""
' process
With grngFiltered
For I = 2 To .Rows.Count
If gsOffer <> "" Then gsOffer = gsOffer & vbCrLf
gsOffer = gsOffer & .Cells(I, 3).Value & gksSeparator & _
.Cells(I, 4).Value & gksSeparator & _
Format(.Cells(I, 5).Value, "ddd dd-mmm-yyyy") & gksSeparator & _
Format(.Cells(I, 6).Value, "ddd dd-mmm-yyyy") & gksSeparator & _
.Cells(I, 7).Value & gksSeparator & .Cells(I, 8).Value
Next I
End With
' end
End Sub

Sub BuildOfferWorkbook()
' constants
' declarations
Dim wb As Workbook, ws As Worksheet
Dim I As Integer
' start
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
' name
gdOffer = Now()
gsWBOffer = ThisWorkbook.Path & Application.PathSeparator & _
gksWBOffer & Format(gdOffer, "yyyymmdd_hhmmss") & gksWBOfferExtension
' process
Set ws = ThisWorkbook.Worksheets(gksWSFiltered)
Set wb = Workbooks.Add
With wb
' paste in target
ws.Copy .Sheets(1)
' command buttons
With .Worksheets(1)
For I = .Shapes.Count To 1 Step -1
.Shapes(I).Delete
Next I
End With
' extra worksheets
For I = .Worksheets.Count To 2 Step -1
.Worksheets(I).Delete
Next I
' save & close
.SaveAs gsWBOffer
.Close
End With
' end
Set ws = Nothing
Set wb = Nothing
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub

Sub ResetFilters()
ActiveSheet.ShowAllData
End Sub

Sub MailStuff(pbSend As Boolean)
' constants
Const ksSubject = "Mail subject"
Const ksText1 = "Dear sir/madame:"
Const ksText2 = "Regarding this reference: "
Const ksText3 = "This is the related offer information (Code, Name, Effective date, Expiration date, Amount, Other data)):"
Const ksText4 = "Signed by XXX."
' declarations
Dim olApp As Object, olMail As Object
Dim sMail As String, sText As String
Dim I As Integer, J As Integer, A As String, bOk As Boolean
Dim sOffer As String
' start
Set grngFiltered = Worksheets(gksWSFiltered).Range(gksFiltered)
Set grngMail = Worksheets(gksWSMail).Range(gksMail)
Set olApp = CreateObject("Outlook.Application")
' process
With grngMail
For I = 2 To .Rows.Count
' create mail
Set olMail = olApp.CreateItem(0)
sMail = .Cells(I, 1).Value
' build body
sText = ksText1 & vbCrLf & _
.Cells(I, 1).Value & vbCrLf & .Cells(I, 2).Value & vbCrLf & _
.Cells(I, 3).Value & vbCrLf & .Cells(I, 4).Value & vbCrLf & _
.Cells(I, 5).Value & vbCrLf & .Cells(I, 6).Value & vbCrLf & _
vbCrLf & _
ksText2 & "Offers sent on " & _
Format(gdOffer, "ddd dd-mmm-yyyy hh:mm:ss") & _
vbCrLf & vbCrLf & _
ksText3 & vbCrLf & _
gsOffer & _
vbCrLf & vbCrLf & _
ksText4
' view/send mail
'=====
'This block of code written by Ron de Bruin, copied from
'http://msdn.microsoft.com/en-us/library/ff458119(office.11).aspx#odc_office_UseExcelObjectModeltoSendMail_Introduction
On Error Resume Next
' Change the body and subject in the macro before you run it.
With olMail
.to = sMail
.CC = ""
.BCC = ""
.Subject = ksSubject
.Body = sText
'You're not sending an attachment, so I commented this out
.Attachments.Add gsWBOffer
' You can add other files by uncommenting the following line.
'.Attachments.Add ("C:test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
If pbSend Then .Send Else .Display
DoEvents
End With
On Error GoTo 0
'=======
' destroy mail
Set olMail = Nothing
Next I
End With
' end
Set olApp = Nothing
Set grngMail = Nothing
Set grngFiltered = Nothing
Beep
End Sub

-----


What I think it lacks but it's your homework is to build a user form for making more secure and user friendly the input of data at worksheet Master.


Just advise if any issue.


Regards!
 
Hi,

Thank you so much for all the effort you put into this!

I am still working on this and you have definitely helped me in the right direction and gave me a great idea!

I appreciate your help.

All the best,

Fern.

Aka Frau Blucher.... just kidding...
 
Hi, Fern Jones!

Glad you solved it. Thanks for your feedback and for your kind words too. And welcome back whenever needed or wanted.

Regards!

PS: What a pity you aren't aka Inga... :)
 
Back
Top