Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 June 30th, 2012, 08:33 AM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Insert Values in Multiple Cells

Hi Guys,
Hope you can help me out with a problem I am having, still fairly new to VBA!

I have a User form with a ComboBox "SKUNumberComboBox" which has a list of SKU Numbers and I have a Date Picker "DTPicker1" were I can pick a date and I also have a TextBox "ExtraDaysTextBox" were I enter the amount of Days.
Basicly when I enter the SKU Number in the "SKUNumberComboBox" and the Date from the "DTPicker1" and I enter a Value of lets say "8" in the "ExtraDaysTextBox" I have code finding the Cell that intersects between the Value in the SKUNumberComboBox" and the "DTPicker1" and from this cell I need to enter the number "1" in the "8" Cells on that row after that with respect to the value in the "ExtraDaysTextBox" which is "8".
I attached the code I have so far so I hope you can help me??


Code:
Const DataSheet = "Data"        ' Sheet with data
Const HatDates = "F2:AWG2"      ' Address of dates
Const HatSKUs = "A2:A1000"       ' Address of SKUs
Const FLAG = 1                  ' flag

Private Sub SetFlag()    ' Set flag in table, enters the number "1" in the appropriate cell
    
    On Local Error GoTo errors
    
    'Looks for the Cell with referance to the SKU and the Date and enters "1"
    With Sheets(DataSheet)
        Set DateFound = .Range(HatDates).Find(what:=DTPicker1.Value)
        Set SKUFound = .Range(HatSKUs).Find(what:=SKUNumberComboBox.Value)
                
        .Cells(SKUFound.Row, DateFound.Column) = FLAG           'Enters "1" in the Cell corrosponding to DTPicker1.Value & SKUNumberComboBox.Value
        
       
             
    End With
Exit Sub


errors:
    MsgBox "Error: " & Err.Description


End Sub
 
Old July 2nd, 2012, 03:08 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

The problem here is the SKURow is not checked for when the Datefound column is checked

Can you please try if Intersect method helps you


Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
The Following User Says Thank You to Shasur For This Useful Post:
Pinkster69 (July 2nd, 2012)
 
Old July 2nd, 2012, 10:26 AM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Shasur,

Thank you so much for your reply!
Looked up Intersect method to see how it worked & tried what you suggested and got it to work.

Thanks again

regards

Derek





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Values in Multiple Cells Pinkster69 Forum and Wrox.com Feedback 0 June 30th, 2012 08:22 AM
multiple values insert into one field mateenmohd Classic ASP Basics 0 May 29th, 2007 02:11 AM
insert multiple records into a table from values Deepak Chauhan Oracle 3 May 12th, 2006 10:35 PM
insert multiple checkbox values in to database [email protected] Pro JSP 0 March 29th, 2006 08:23 AM
How t o insert multiple values qazi_nomi Access ASP 2 May 3rd, 2005 12:45 AM





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