I need help with reccurrence when it comes to coding

Joenne

New Member
Joined
May 21, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Private Sub CommandButton2_Click()

If Me.ComboBox1 = Database.Range("C2") And Me.ComboBox2 = Database.Range("C3") Then
Database.Range("A2:C2").Copy
Database.Range("A100:C100").Insert
Database.Range("A3:C3").Copy
Database.Range("A2:C2").PasteSpecial
Database.Range("A100:C100").Copy
Database.Range("A3:C3").PasteSpecial
Database.Range("A100:C100").clear
Database.Range("C2:C81").Sort Key1:=Database.Range("C2"), Order1:=xlAscending, Header:=xlYes


End If
End Sub

I need this above statement to be able til work throughout the sheet - range C2:C81
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,886
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Board!

I think we need a little bit more information.
Are you saying that you want this code to cycle through rows 2-81 every time it runs?
Or run on one row, as long as it falls within that range (if so, how does it know which row to run on)?

It might be helpful if you can do the following:
1. Explain, in plain English, exactly what you want your code to do (I do not like to try to "guess" based on how code is written, as I often find that the code may not be written correctly).
2. Show a sample of your data, and what your expected results should look like.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,120
Messages
5,768,224
Members
425,460
Latest member
Astros1243

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
Top