Results 1 to 7 of 7

Excel/VBA for Creative Problem Solving, Part 1 - Exercise nor succesful

Threaded View

  1. #1
    Registered User
    Join Date
    09-20-2024
    Location
    Madrid
    MS-Off Ver
    16.52
    Posts
    12

    Excel/VBA for Creative Problem Solving, Part 1 - Exercise nor succesful

    Hi all

    I am trying to improve my skills with excel/VBA as I need it for my job. I started the course Excel/VBA for Creative Problem Solving, Part 1 in coursera and I am on module 2.
    As far as I can see, my macro is correct. It works for me in my PC, but for some reason its failing in part C. Please, could you help me find what I am doing wrong?
    x100000 thanks.

    The exercise says the following

    INSTRUCTIONS:

    a) Create a subroutine called AddNumbersA that adds a number input into an input box to the value in cell D4. The result should be output in cell G12.

    b) Create a subroutine called AddNumbersB that asks the user for a number, adds that number to the value in the active cell, then places the result in a cell that is 3 rows up and two columns right of the active cell. (Make sure that you select an appropriate active cell prior to running the sub!)

    c) Create a subroutine called WherePutMe that asks the user for a row number and column letter then places the 2,2 position of a selection into that cell. (HINT: Make sure that you select a selection before running the sub!)

    HINT: If x is an integer and is equal to 7 and y is a string and equal to "B", you can place z into cell B7 by: Range(y & x) = z. Hope this helps.

    1. Start with a selection:
    2. Run your WherePutMe subroutine, which asks the user for the row and column of the cell in which they’d like to place the result:
    3. Your subroutine will take the 2,2 position of the initial selection (-4 in our example) and place it in cell C7 (specified by user in the two input boxes):


    d) Create a subroutine called Swap that will swap the values in two adjacent cells (in the same row, anywhere on the spreadsheet). (Make sure that you select two adjacent cells before executing the sub!).

    And my code is this

    Option Explicit
    
    
    Sub AddNumbersA()
    
    'Place your code here
    
    Dim x As Double, y As Double, z As Double
    
    x = InputBox("Please, enter a Number:")
    
    y = Range("D4")
    
    z = x + y
    
    Range("G12") = z
    
    
    End Sub
    
    
    Sub AddNumbersB()
    
    'Place your code here
    
    Dim x As Double, y As Double, z As Double
    
    x = InputBox("Please, enter a Number:")
    
    y = ActiveCell
    
    z = x + y
    
    ActiveCell.Offset(-3, 2) = z
    
    
    End Sub
    
    
    Sub WherePutMe()
    
    'Place your code here
    
    Dim x As Integer, y As String, z As String, n As Integer
    
    x = InputBox("Please, enter a Number:")
    
    y = InputBox("Please, enter a Letter:")
    
    z = y & x
    
    Selection.Range(z).Select
    
    n = Selection
    
    Range(z).Offset(2, 2) = n
    
    
    End Sub
    
    
    
    Sub Swap()
    
    'Place your code here
    
    Dim temp As Integer, b As Integer
    
    temp = Selection.Cells(1, 1)
    
    b = Selection.Cells(1, 2)
    
    Selection.Cells(1, 2) = temp
    
    Selection.Cells(1, 1) = b
    
    
    End Sub
    Can you guys please help me? I have also attached the file.

    Thanks a lot
    Attached Files Attached Files
    Last edited by MeryFlower.1983; 10-12-2024 at 03:26 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel VBA For Creative Problem Solving Part 1 Assignment 4
    By chiky1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2025, 10:35 AM
  2. [SOLVED] Excel VBA For Creative Problem Solving Part 1 Assignment 4: Help Needed
    By chollerauer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2024, 02:39 AM
  3. Excel VBA For Creative Problem Solving Part 1 Assignment 4
    By YuliaUK in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-16-2024, 12:52 PM
  4. Excel VBA For Creative Problem Solving Part 1 Assignment 4
    By Astec in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-19-2023, 05:31 PM
  5. Help Needed: Excel VBA For Creative Problem Solving Part 1 Assignment 4
    By webcam723 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-04-2023, 08:28 PM
  6. Kindly Help in Solving this Excel Problem
    By yousufsaleem in forum Excel General
    Replies: 1
    Last Post: 12-07-2015, 06:37 PM
  7. Thorny VBA problem. Any creative solution appreciated.
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2005, 06:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1