please help with vba coding

tango71

New Member
Joined
Aug 27, 2019
Messages
12
Ok, so what i am trying to do is to use a vb form to view ranges on a worksheet. i dont want to change anythin but i do want to scroll through to the last row that has data. that being said, i have literally tried everything i can think of short of just writing a java script and doing what i need through there. i am an amateur at vba but do understand how coding works.
some of the things i have tried are
Code:
Worksheets("Register").Range("A1:G22000").PrintPreview
i have tried linking data to a label.
linking to a list box, a text box, you name it ive tried it. just cant get it to display anything.
I know it is probably something stupid simple that im just missing. ive been working on this for about 3 hours
i guess im just not getting it. Please help.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi & welcome to MrExcel.
If you are talking about a Listbox on a UserForm, try
Code:
Private Sub UserForm_Initialize()
   Me.ListBox1.List = Sheets("Register").Range("A1:G22000").Value
End Sub
 
Upvote 0
Hi @★tango71 and welcome to the forum.

Try this.

Change the showmodal property of your userform to False.

77a0dedee091e96374bc606deeb1d96b.jpg


Put the following code on a button in your userform:

Code:
Private Sub CommandButton1_Click()
  Dim sh As Worksheet
  Set sh = Sheets("Register")
  sh.PageSetup.PrintArea = "A1:G22000"
  sh.PrintPreview
End Sub
 
Upvote 0
thanks for the info, i did try entering that into the form code. However, im still at square 1. it pops up but absolutely no values of the sheet are showing in the listbox. i even checked the properties thinking that maybe the text color wasnt black. cant seem to figure it out.
 
Upvote 0
I just tried your way Dante, and I placed a command button on the form and used the code and it literally froze. I think im running out of options. I have done this easily in visual basic about 15 years ago, but cant seem to remember how to get it to work.
 
Upvote 0
I just tried your way Dante, and I placed a command button on the form and used the code and it literally froze. I think im running out of options. I have done this easily in visual basic about 15 years ago, but cant seem to remember how to get it to work.


This is important:

Change the showmodal property of your userform to False.
 
Upvote 0
yes, i did that and it still froze the spreadsheet when i ran it. It looked like it was going to work. i do not get it. i even went as far as trying a dynamic range to see if i could get it to work that way.... I am completely stumped on this one.
 
Upvote 0
Are you trying to use the PrintPreview screen, or are you trying to put data into a listbox?
 
Upvote 0
yes, i did that and it still froze the spreadsheet when i ran it. It looked like it was going to work. i do not get it. i even went as far as trying a dynamic range to see if i could get it to work that way.... I am completely stumped on this one.

That way you can scroll to the Printpreview, the userform is frozen, but you can move in the Printpreview, when you press Esc the control returns to userform.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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