PC Review


Reply
Thread Tools Rate Thread

Copy paste code for a #REF

 
 
LiAD
Guest
Posts: n/a
 
      15th Dec 2009
Hi,

I am looking for a workbook code that runs when the file is opened. In col
H I have a formula (=INDIRECT(G8)) which searches data from another series of
folders. If the source folder is open it returns either a value or 0. If
the relevant source file is closed it returns a #REF.

What I would like is a code that looks through all the cells in Col H, if it
finds a numerical value or 0 it does a copy/paste values on the cells, if it
finds a #REF it does nothing.

The file is a update folder so the REFs will be in the future and the values
in the current/past which i need to keep to stop updates and allow the values
to be viewed irrespective of which folders are opened/closed.

Is this possible?
Thanks
LiAD
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      15th Dec 2009
Hi,

Try this with the worksheet changed to suit. Note that changing a formula to
UCASE has the effect of converting it to a value

Sub sonic()
Dim ws As Worksheet
Set ws = Sheets("Sheet1") 'Change to suit
lastrow = ws.Cells(Cells.Rows.Count, "H").End(xlUp).Row
Set MyRange = ws.Range("H1:H" & lastrow)
For Each c In MyRange
If IsNumeric(c.Value) Then
c.Value = UCase(c.Value)
End If
Next
End Sub

Mike

"LiAD" wrote:

> Hi,
>
> I am looking for a workbook code that runs when the file is opened. In col
> H I have a formula (=INDIRECT(G8)) which searches data from another series of
> folders. If the source folder is open it returns either a value or 0. If
> the relevant source file is closed it returns a #REF.
>
> What I would like is a code that looks through all the cells in Col H, if it
> finds a numerical value or 0 it does a copy/paste values on the cells, if it
> finds a #REF it does nothing.
>
> The file is a update folder so the REFs will be in the future and the values
> in the current/past which i need to keep to stop updates and allow the values
> to be viewed irrespective of which folders are opened/closed.
>
> Is this possible?
> Thanks
> LiAD

 
Reply With Quote
 
LiAD
Guest
Posts: n/a
 
      15th Dec 2009
Perfect

thanks

"Mike H" wrote:

> Hi,
>
> Try this with the worksheet changed to suit. Note that changing a formula to
> UCASE has the effect of converting it to a value
>
> Sub sonic()
> Dim ws As Worksheet
> Set ws = Sheets("Sheet1") 'Change to suit
> lastrow = ws.Cells(Cells.Rows.Count, "H").End(xlUp).Row
> Set MyRange = ws.Range("H1:H" & lastrow)
> For Each c In MyRange
> If IsNumeric(c.Value) Then
> c.Value = UCase(c.Value)
> End If
> Next
> End Sub
>
> Mike
>
> "LiAD" wrote:
>
> > Hi,
> >
> > I am looking for a workbook code that runs when the file is opened. In col
> > H I have a formula (=INDIRECT(G8)) which searches data from another series of
> > folders. If the source folder is open it returns either a value or 0. If
> > the relevant source file is closed it returns a #REF.
> >
> > What I would like is a code that looks through all the cells in Col H, if it
> > finds a numerical value or 0 it does a copy/paste values on the cells, if it
> > finds a #REF it does nothing.
> >
> > The file is a update folder so the REFs will be in the future and the values
> > in the current/past which i need to keep to stop updates and allow the values
> > to be viewed irrespective of which folders are opened/closed.
> >
> > Is this possible?
> > Thanks
> > LiAD

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cut, Copy, Paste code John Microsoft Dot NET Framework Forms 10 18th Jan 2010 09:37 AM
Cut, Copy, Paste code John Microsoft VB .NET 9 19th May 2008 01:00 AM
Code for Copy/Paste PD Microsoft Access Form Coding 10 21st Feb 2008 01:40 PM
I keep getting this code <o:p> when I copy and paste. =?Utf-8?B?U2NhcnI=?= Microsoft Word Document Management 3 16th Feb 2007 07:18 PM
Copy and paste code =?Utf-8?B?UmF5byBL?= Microsoft Excel Programming 1 12th Oct 2006 05:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 AM.