Help with a developer tool to be able to change data in certain cells

suzette0735

New Member
Joined
Jul 12, 2023
Messages
31
Office Version
  1. 365
Platform
  1. Windows
I am working on a spreadsheet that has mark up % in many of the cells in one column. When we want to change all of them to be the same mark up I would like it to be as easy as the click of a button. For example: I want them all to be 25%, or 50% or 10% I want to be able to just select that or input it into a cell and it changes all of the mark up %. However, I do not want to write a formula that would link all of those to one cell where as if I wanted to manually change one it would erase that formula in that particular cell. Does this make sense? Can anyone help with this? Thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Something like this perhaps:
VBA Code:
Private Sub UpdateMarkUp()
Range("A2:A20") = Range("B2")
End Sub

Which can be easily tied to a button or double clicking a specific cell, or entering a specific value, etc.
 
Upvote 0
How about code like this?
VBA Code:
Sub MarkUp()

    Dim pct As Byte
    Dim cell As Range
    
    Application.ScreenUpdating = False
    
'   Prompt user for percent of markup
    pct = InputBox("Please enter percent of markup as whole number without percent sign")
    
'   Multiply selected range by markup
    For Each cell In Selection
        If cell <> "" And IsNumeric(cell) Then cell.Value = cell.Value * (1 + (pct / 100))
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub

The way that it works is if you started with something like this:
1725911371085.png


and wanted to increase each by 25%, what you would do is:
- select the range you want to update (A2:A6 in this example)
- run the "MarkUp" procedure
- enter in your desired percentage (25) as shown below:

1725911438846.png


and then you would end up with this:
1725911454667.png
 
Upvote 0
Something like this perhaps:
VBA Code:
Private Sub UpdateMarkUp()
Range("A2:A20") = Range("B2")
End Sub

Which can be easily tied to a button or double clicking a specific cell, or entering a specific value, etc.
Thank you! I am new to this and I do not think I did it right. Please see attachments. There are two different ranges I tried it on and the first went blank and the 2nd nothing happened. Thanks for you help!
 

Attachments

  • Screenshot 2024-09-09 150308.png
    Screenshot 2024-09-09 150308.png
    44.4 KB · Views: 4
  • Screenshot 2024-09-09 150207.png
    Screenshot 2024-09-09 150207.png
    4.7 KB · Views: 4
Upvote 0
How about code like this?
VBA Code:
Sub MarkUp()

    Dim pct As Byte
    Dim cell As Range
   
    Application.ScreenUpdating = False
   
'   Prompt user for percent of markup
    pct = InputBox("Please enter percent of markup as whole number without percent sign")
   
'   Multiply selected range by markup
    For Each cell In Selection
        If cell <> "" And IsNumeric(cell) Then cell.Value = cell.Value * (1 + (pct / 100))
    Next cell
   
    Application.ScreenUpdating = True
   
End Sub

The way that it works is if you started with something like this:
View attachment 116651

and wanted to increase each by 25%, what you would do is:
- select the range you want to update (A2:A6 in this example)
- run the "MarkUp" procedure
- enter in your desired percentage (25) as shown below:

View attachment 116653

and then you would end up with this:
View attachment 116654
This is great ! Thank you! I will see if it works for us :)
 
Upvote 0
Thank you! I am new to this and I do not think I did it right. Please see attachments. There are two different ranges I tried it on and the first went blank and the 2nd nothing happened. Thanks for you help!
Okay, you have some errors in the code. Try this:
VBA Code:
Sub Button15_Click()
Dim rng As Range
Set rng = Application.Union(Range("N14:N133"), Range("N142:N221"))
rng = Range("N12")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,755
Messages
6,180,758
Members
452,996
Latest member
nelsonsix66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top