Solved

Writing a range of data to the registry, contained within 1 registrey entry

Posted on 2016-09-18
11
40 Views
Last Modified: 2016-10-09
Hi,

I have tried several methods but failed...

I need help to write a range, say A1:D20 to the registry using a key defined by the date for example DC2016.09.18 {data}

Therefore everyday the same range is stored to a new key, and I will also need to recover this information.

Thanx
0
Comment
Question by:StormFusion
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 250 total points (awarded by participants)
ID: 41803649
You cannot write a range to one registry key.
Perhaps if you elaborate on what you're trying to accomplish we can better assist you.
0
 

Author Comment

by:StormFusion
ID: 41803650
I have a grid of data values, 10 rows by 10 cols, I would like to store this in the registry as comma deliminated to a data key, so later on I can retrieve the sequence for a particular date, therefore my users only need to load a central sheet and the data is fed from there local registry.
0
 
LVL 92

Assisted Solution

by:John Hurst
John Hurst earned 250 total points (awarded by participants)
ID: 41803657
The registry is not a user tool, it is secured, and not meant to be file storage.

Why use the registry? That is, what did I not consider?
Why not use a file?
0
 

Author Comment

by:StormFusion
ID: 41803662
You that may work, I prefer registry because its there!.

How would I write a range to a file and retrieve it?

Thx
0
 
LVL 92

Assisted Solution

by:John Hurst
John Hurst earned 250 total points (awarded by participants)
ID: 41803673
The registry is there but not for you to use it.

You would have to unsecure the registry to do this. Why?

Leave it alone and use the correct tools.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 250 total points (awarded by participants)
ID: 41803706
Here is one way (there are others).
Use DumpRange to dump the range to a csv file and GrabFile to read that csv file.

Sub DumpRange()
    Dim rng As Range
    Dim strFile As String
    rng = Range("A1:J10")                           ' set range to export
    strFile = ActiveWorkbook.Path & "\Demo.csv"     ' set file path for exported file
    Call DumpRangeToTextFile(rng, strFile)
End Sub

Sub GrabFile()
    Dim strFile As String
    Dim iFile As Integer
    Dim strData As String
    strFile = ActiveWorkbook.Path & "\Demo.csv"     ' set file path for exported file
    iFile = FreeFile
    Open strFile For Input As #iFile
    strData = Input$(LOF(iFile), iFile)             ' now the strData variable contains the data
    Close #iFile
End Sub

Function DumpRangeToTextFile(rngSource As Range, strFile As String)
    Dim iFile As Integer
    Dim rng As Range, cell As Range
    iFile = FreeFile
    Open strFile For Output As #iFile
    For Each rng In rngSource.Rows
        For Each cell In rng.Cells
            Print #iFile, cell.Value;
        Next cell
        Write #iFile,
    Next rng
    Close #iFile
End Function

Open in new window

0
 

Author Comment

by:StormFusion
ID: 41803918
Ok, thankyou for that, after I set set rng manged to get it to work, it writes the data to a file as if its printed which is ok, but when I recover the data and place into a cell I get an copy of such, problem with that is I need it to mirror whats been taken,

So if I save range A10:G50 for example this is comma deliminated to a file, when I import the data goes back into A10:G50.

Thank you
0
 
LVL 92

Assisted Solution

by:John Hurst
John Hurst earned 250 total points (awarded by participants)
ID: 41803923
The registry format is not related to any Excel format so you would have to import the data.
0
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 250 total points (awarded by participants)
ID: 41804290
@StormFusion
I'm not sure I understood you. can you please elaborate (perhaps with examples)?
0
 
LVL 33

Expert Comment

by:Norie
ID: 41807620
Do you want to store actual range objects?

If you do then I don't think it's going to be possible unless you actually copied/stored them in another worksheet.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now