Wrox Programmer Forums
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 3rd, 2010, 02:42 PM
Registered User
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA Help with formula

I am writing a module to read cells from one worksheet and place the value in another worksheet in the same workbook. I am using variables within my loop to read through the rows. I am getting a error in the formula. I am sure it has to do with where I have the quotes. Below is part of the code. Help will be much appreciated. As you will see in the code I have tried referencing by cells 2 different ways and both give me an error. I can make this work by assigning to a variable, but would rather directly address the cells.
Sub GiftImportData()
Dim myrow As Long, myAssoc As Long, myAmtUSD As Double, myGiftOff As String, myGiftType As String
Dim mySegCode As String, myrowGift As Long

myrow = 2
myrowGift = 11

Do Until IsEmpty(Range("a" & myrow)) Or Range("a" & myrow) = ""

Worksheets("giftimportdata").Range("A" & myrowGift).Formula = "='Raw Data'!" & "Range(""c"" & myrow & ).value"
Range("B" & myrowGift).Formula = "='Raw Data'!" & Cells(myrow, 13) & ".value"

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Insert formula Swift4Play BOOK: Excel 2003 VBA Programmer's Reference 0 December 1st, 2009 04:15 PM
Translating WorkSheet Formula in VBA AndyL Beginning VB 6 2 June 11th, 2008 04:13 AM
Excel formula not working in vba yogeshyl Excel VBA 2 December 12th, 2007 02:27 AM
Excel formula not working in VBA yogeshyl Excel VBA 2 July 19th, 2007 03:57 AM
Problems introducing a formula using VBA mariona_cid Excel VBA 0 June 1st, 2004 07:01 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.